Skip to content

Conversation

@harshampatel-sysdig
Copy link
Collaborator

@harshampatel-sysdig harshampatel-sysdig commented Oct 30, 2025

Key changes:

  • Added resource and data source for sysdig_secure_okta_ml_policy
  • Implemented CRUD operations with proper error handling
  • Added tests and documentation

@harshampatel-sysdig harshampatel-sysdig marked this pull request as draft October 30, 2025 00:51
@harshampatel-sysdig harshampatel-sysdig marked this pull request as ready for review October 30, 2025 01:15
Copy link

@daniel-almeida daniel-almeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments. I'll let someone else look at the implication of the changes as I don't have any experience with this repo.

@@ -0,0 +1,15 @@
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to push this. If you can, please add it to gitignore so this isn't tracked in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to delete it from your local machine and push once to remove it from here

Comment on lines 709 to 710
// TODO: Iterate over a list of rules instead of hard-coding the index values
// TODO: Should we assume that only a single Malware rule can be attached to a policy?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These TODOs are intentionally kept to match the AWS ML implementation pattern. Both AWS ML and Okta ML policies currently support a single rule per policy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now yes the behavior is 1 rule per policy for these non-Falco types like malware, drift and ML ones. So we can remove the comment if needed

})
}

_ = d.Set("rule", rules)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an error being ignored? We should handle it if so.

}

func oktaMLPolicyFromResourceData(d *schema.ResourceData) (v2.PolicyRulesComposite, error) {
policy := &v2.PolicyRulesComposite{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there's similar code for other types, but I think it makes more sense to avoid the pointer in this function and pass &policy to oktaMLPolicyReducer, which is where a pointer is actually needed.

return diag.FromErr(err)
}

id, _ := strconv.Atoi(d.Id())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's handle the error here.

Copy link
Contributor

@ombellare ombellare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments. Let me know if you want me to add it to your other branch that you plan to merge

@@ -0,0 +1,15 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to delete it from your local machine and push once to remove it from here

Comment on lines 709 to 710
// TODO: Iterate over a list of rules instead of hard-coding the index values
// TODO: Should we assume that only a single Malware rule can be attached to a policy?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now yes the behavior is 1 rule per policy for these non-Falco types like malware, drift and ML ones. So we can remove the comment if needed


* `anomalous_console_login` - Anomaly detection settings for logins.
* `enabled` - Whether anomaly detection is enabled.
* `threshold` - Confidence level threshold for triggering alerts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add that only supported values for the threshold are 1, 2 and 3 please? If you would like you can update for the other ML types as well (I think they were missed there too)


* `description` - (Required) Rule description.
* `anomalous_console_login` - (Required) This attribute allows you to activate anomaly detection for logins and adjust its settings.
* `threshold` - (Required) Trigger at or above confidence level.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be an enabled field here too similar to how you have on your data source.

Changed threshold value descriptions from 'High/Medium/Low' to 'Default/High/Higher' for ML policies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants