diff --git a/.apigentools-info b/.apigentools-info index 8023490d63d..92cfd5affbb 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-05-22 20:06:48.360377", - "spec_repo_commit": "94c7d978" + "regenerated": "2024-05-23 11:00:08.137912", + "spec_repo_commit": "b829bfa2" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-05-22 20:06:48.378411", - "spec_repo_commit": "94c7d978" + "regenerated": "2024-05-23 11:00:08.169625", + "spec_repo_commit": "b829bfa2" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 8575f7f5f14..c904282b709 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -4105,6 +4105,11 @@ components: description: The SECL expression of the Agent rule. example: exec.file.name == \"sh\" type: string + filters: + description: The platforms the Agent rule is supported on. + items: + type: string + type: array name: description: The name of the Agent rule. example: my_agent_rule diff --git a/api/datadogV2/model_cloud_workload_security_agent_rule_create_attributes.go b/api/datadogV2/model_cloud_workload_security_agent_rule_create_attributes.go index f72687d4b57..3fd2950b8cc 100644 --- a/api/datadogV2/model_cloud_workload_security_agent_rule_create_attributes.go +++ b/api/datadogV2/model_cloud_workload_security_agent_rule_create_attributes.go @@ -18,6 +18,8 @@ type CloudWorkloadSecurityAgentRuleCreateAttributes struct { Enabled *bool `json:"enabled,omitempty"` // The SECL expression of the Agent rule. Expression string `json:"expression"` + // The platforms the Agent rule is supported on. + Filters []string `json:"filters,omitempty"` // The name of the Agent rule. Name string `json:"name"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -123,6 +125,34 @@ func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) SetExpression(v string) o.Expression = v } +// GetFilters returns the Filters field value if set, zero value otherwise. +func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) GetFilters() []string { + if o == nil || o.Filters == nil { + var ret []string + return ret + } + return o.Filters +} + +// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) GetFiltersOk() (*[]string, bool) { + if o == nil || o.Filters == nil { + return nil, false + } + return &o.Filters, true +} + +// HasFilters returns a boolean if a field has been set. +func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) HasFilters() bool { + return o != nil && o.Filters != nil +} + +// SetFilters gets a reference to the given []string and assigns it to the Filters field. +func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) SetFilters(v []string) { + o.Filters = v +} + // GetName returns the Name field value. func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) GetName() string { if o == nil { @@ -159,6 +189,9 @@ func (o CloudWorkloadSecurityAgentRuleCreateAttributes) MarshalJSON() ([]byte, e toSerialize["enabled"] = o.Enabled } toSerialize["expression"] = o.Expression + if o.Filters != nil { + toSerialize["filters"] = o.Filters + } toSerialize["name"] = o.Name for key, value := range o.AdditionalProperties { @@ -170,10 +203,11 @@ func (o CloudWorkloadSecurityAgentRuleCreateAttributes) MarshalJSON() ([]byte, e // UnmarshalJSON deserializes the given payload. func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Description *string `json:"description,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Expression *string `json:"expression"` - Name *string `json:"name"` + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Expression *string `json:"expression"` + Filters []string `json:"filters,omitempty"` + Name *string `json:"name"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -186,13 +220,14 @@ func (o *CloudWorkloadSecurityAgentRuleCreateAttributes) UnmarshalJSON(bytes []b } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "expression", "name"}) + datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "expression", "filters", "name"}) } else { return err } o.Description = all.Description o.Enabled = all.Enabled o.Expression = *all.Expression + o.Filters = all.Filters o.Name = *all.Name if len(additionalProperties) > 0 { diff --git a/examples/v2/csm-threats/CreateCSMThreatsAgentRule.go b/examples/v2/csm-threats/CreateCSMThreatsAgentRule.go index 8efb12ef04b..921d6e9af2b 100644 --- a/examples/v2/csm-threats/CreateCSMThreatsAgentRule.go +++ b/examples/v2/csm-threats/CreateCSMThreatsAgentRule.go @@ -19,7 +19,10 @@ func main() { Description: datadog.PtrString("My Agent rule"), Enabled: datadog.PtrBool(true), Expression: `exec.file.name == "sh"`, - Name: "examplecsmthreat", + Filters: []string{ + `os == "linux"`, + }, + Name: "examplecsmthreat", }, Type: datadogV2.CLOUDWORKLOADSECURITYAGENTRULETYPE_AGENT_RULE, }, diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.freeze index bff050d55d1..42b749c2db2 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.freeze @@ -1 +1 @@ -2024-04-23T17:57:44.371Z \ No newline at end of file +2024-05-22T16:22:22.200Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.yaml index 7fada680809..4396f0538f8 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_CSM_Threats/Scenario_Create_a_CSM_Threats_Agent_rule_returns_OK_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testcreateacsmthreatsagentrulereturnsokresponse1713895064"},"type":"agent_rule"}} + {"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","filters":["os == \"linux\""],"name":"testcreateacsmthreatsagentrulereturnsokresponse1716394942"},"type":"agent_rule"}} form: {} headers: Accept: @@ -12,10 +12,10 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules response: - body: '{"data":{"id":"922-a60-32v","type":"agent_rule","attributes":{"category":"Process - Activity","creationDate":1713895064438,"creator":{"name":"","handle":"frog@datadoghq.com"},"defaultRule":false,"description":"My + body: '{"data":{"id":"pn4-mo8-u5r","type":"agent_rule","attributes":{"category":"Process + Activity","creationDate":1716394942614,"creator":{"name":"","handle":"frog@datadoghq.com"},"defaultRule":false,"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","filters":["os - == \"linux\""],"name":"testcreateacsmthreatsagentrulereturnsokresponse1713895064","updateDate":1713895064438,"updater":{"name":"","handle":"frog@datadoghq.com"}}}}' + == \"linux\""],"name":"testcreateacsmthreatsagentrulereturnsokresponse1716394942","updateDate":1716394942614,"updater":{"name":"","handle":"frog@datadoghq.com"}}}}' code: 200 duration: 0ms headers: @@ -30,7 +30,7 @@ interactions: - '*/*' id: 1 method: DELETE - url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/922-a60-32v + url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/pn4-mo8-u5r response: body: '' code: 204 diff --git a/tests/scenarios/features/v2/csm_threats.feature b/tests/scenarios/features/v2/csm_threats.feature index 9de7fc15e0a..739dee5a604 100644 --- a/tests/scenarios/features/v2/csm_threats.feature +++ b/tests/scenarios/features/v2/csm_threats.feature @@ -28,7 +28,7 @@ Feature: CSM Threats @team:DataDog/k9-cloud-security-platform @team:DataDog/k9-cws-backend Scenario: Create a CSM Threats Agent rule returns "OK" response Given new "CreateCSMThreatsAgentRule" request - And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\"", "name": "{{ unique_lower_alnum }}"}, "type": "agent_rule"}} + And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\"", "filters": ["os == \"linux\""], "name": "{{ unique_lower_alnum }}"}, "type": "agent_rule"}} When the request is sent Then the response status is 200 OK