Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[datadog_security_monitoring_default_rule] Add support for custom tags in security monitoring default rules #2399

Merged
merged 11 commits into from
May 21, 2024

Conversation

paul-hf
Copy link
Contributor

@paul-hf paul-hf commented May 9, 2024

Adds support for custom tags for default rules. Tested updating the tags in staging to confirm it works as expected.

https://datadoghq.atlassian.net/browse/SEC-12971

@paul-hf paul-hf requested review from a team as code owners May 9, 2024 15:25
@paul-hf paul-hf changed the title [SEC-12971] Add support for custom tags in security monitoring default rules [datadog_security_monitoring_default_rule] Add support for custom tags in security monitoring default rules May 9, 2024
clementgbcn
clementgbcn previously approved these changes May 9, 2024
Copy link
Contributor

@clementgbcn clementgbcn left a comment

Choose a reason for hiding this comment

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

I left two small comments.

@@ -110,6 +115,14 @@ resource "datadog_security_monitoring_default_rule" "acceptance_test" {
options {
decrease_criticality_based_on_env = true
}

tags = [
"iaas:aws",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could you fix the indentation (same for the next file)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tabs vs spaces 🫠 Seems like gofmt does not run automatically here? Fixed

"tags": {
Type: schema.TypeSet,
Optional: true,
Description: "Tags for generated signals.",
Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 suggestion: Could you add the fact that: Tags must contain all OOTB rule tags.‏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to the description. One thing I realized is that anyone upgrading to this version of our terraform provider will have to import all these tags initially, and they'll also have to import them any time we change the tags on a default rule. I just want to confirm that's expected and there's no better way to do this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point.
You are right, it could be an issue for rule update.
I think we should append to existing ones (by doing a get before doing the put).

hestonhoffman
hestonhoffman previously approved these changes May 9, 2024
@paul-hf paul-hf dismissed stale reviews from hestonhoffman and clementgbcn via b336651 May 10, 2024 13:33
@paul-hf paul-hf requested a review from clementgbcn May 10, 2024 14:30
…eld to implement custom tags terraform field
@paul-hf paul-hf requested a review from a team as a code owner May 13, 2024 18:56
@paul-hf paul-hf requested a review from Barbayar May 13, 2024 18:56
if i.cloudWorkloadSecurityApiV2 == nil {
i.cloudWorkloadSecurityApiV2 = datadogV2.NewCloudWorkloadSecurityApi(i.HttpClient)
// GetCSMThreatsApiV2 get instance of CSMThreatsApi
func (i *ApiInstances) GetCSMThreatsApiV2() *datadogV2.CSMThreatsApi {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The underlying datadog package had a rename from datadogV2.CloudSecurityWorkloadApi to datadogV2.CSMThreatsApi so I did a find and replace to update the name

@paul-hf
Copy link
Contributor Author

paul-hf commented May 15, 2024

@clementgbcn As we discussed, I've updated this PR to use the new default tags field from the datadog api and I've also made two necessary changes to accommodate the package version bump which I've explained in comments above. This is ready to be reviewed again

@paul-hf
Copy link
Contributor Author

paul-hf commented May 17, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented May 17, 2024

🚂 MergeQueue

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

@paul-hf
Copy link
Contributor Author

paul-hf commented May 17, 2024

/merge -c

@dd-devflow
Copy link

dd-devflow bot commented May 17, 2024

⚠️ MergeQueue

This merge request was unqueued

If you need support, contact us on Slack #devflow!

@paul-hf paul-hf requested a review from hestonhoffman May 17, 2024 13:38
@skarimo skarimo merged commit f66878f into master May 21, 2024
16 of 17 checks passed
@skarimo skarimo deleted the paul-hf/default_rule_tags branch May 21, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants