From 2b9c33b4a5ee69dce66d1eefa85f33ecb1e11c48 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 16:51:47 -0400 Subject: [PATCH] Use unique name for CWS rule (#59) Co-authored-by: ci.datadog-api-spec Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: skarimo <40482491+skarimo@users.noreply.github.com> --- .apigentools-info | 8 ++++---- ...-workload-security_create_csm_threats_agent_rule.rs | 2 +- ...eats-Agent-rule-returns-Bad-Request-response.frozen | 2 +- ...hreats-Agent-rule-returns-Bad-Request-response.json | 6 +++--- ...a-CSM-Threats-Agent-rule-returns-OK-response.frozen | 2 +- ...e-a-CSM-Threats-Agent-rule-returns-OK-response.json | 10 +++++----- .../features/v2/cloud_workload_security.feature | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.apigentools-info b/.apigentools-info index 8edbd6a78..30963f24f 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-03-27 22:12:41.503072", - "spec_repo_commit": "85625198" + "regenerated": "2024-03-28 14:36:52.852799", + "spec_repo_commit": "a462e143" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-03-27 22:12:41.520431", - "spec_repo_commit": "85625198" + "regenerated": "2024-03-28 14:36:52.870334", + "spec_repo_commit": "a462e143" } } } \ No newline at end of file diff --git a/examples/v2_cloud-workload-security_create_csm_threats_agent_rule.rs b/examples/v2_cloud-workload-security_create_csm_threats_agent_rule.rs index ec3cdb51b..062e48a63 100644 --- a/examples/v2_cloud-workload-security_create_csm_threats_agent_rule.rs +++ b/examples/v2_cloud-workload-security_create_csm_threats_agent_rule.rs @@ -12,7 +12,7 @@ async fn main() { CloudWorkloadSecurityAgentRuleCreateData::new( CloudWorkloadSecurityAgentRuleCreateAttributes::new( r#"exec.file.name == "sh""#.to_string(), - "my_agent_rule".to_string(), + "examplecloudworkloadsecurity".to_string(), ) .description("My Agent rule".to_string()) .enabled(true), diff --git a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.frozen index c8506d59b..8ad43c5ec 100644 --- a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.frozen +++ b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.frozen @@ -1 +1 @@ -2024-03-08T14:19:01.846Z \ No newline at end of file +2024-03-28T13:57:47.808Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.json index 8242aa6ef..b3163307a 100644 --- a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.json +++ b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-Bad-Request-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"data\":{\"attributes\":{\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == sh\",\"name\":\"my_agent_rule\"},\"type\":\"agent_rule\"}}", + "string": "{\"data\":{\"attributes\":{\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == sh\",\"name\":\"testcreateacsmthreatsagentrulereturnsbadrequestresponse1711634267\"},\"type\":\"agent_rule\"}}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"errors\":[\"input_validation_error(Field 'expression' is invalid: rule `my_agent_rule` error: rule compilation error: field `sh` not found)\"]}", + "string": "{\"errors\":[\"input_validation_error(Field 'expression' is invalid: rule `testcreateacsmthreatsagentrulereturnsbadrequestresponse1711634267` error: rule compilation error: field `sh` not found)\"]}", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "Bad Request" } }, - "recorded_at": "Fri, 08 Mar 2024 14:19:01 GMT" + "recorded_at": "Thu, 28 Mar 2024 13:57:47 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.frozen index 4ff817ba6..5c5d9638b 100644 --- a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.frozen @@ -1 +1 @@ -2024-03-08T14:19:02.357Z \ No newline at end of file +2024-03-28T13:57:48.169Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.json b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.json index 1d8d9b759..2442d5288 100644 --- a/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.json +++ b/tests/scenarios/cassettes/v2/cloud_workload_security/Create-a-CSM-Threats-Agent-rule-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"data\":{\"attributes\":{\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"name\":\"my_agent_rule\"},\"type\":\"agent_rule\"}}", + "string": "{\"data\":{\"attributes\":{\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"name\":\"testcreateacsmthreatsagentrulereturnsokresponse1711634268\"},\"type\":\"agent_rule\"}}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"data\":{\"id\":\"zer-ow9-d4q\",\"type\":\"agent_rule\",\"attributes\":{\"category\":\"Process Activity\",\"creationDate\":1709907542607,\"creator\":{\"name\":\"Malo Le Goff\",\"handle\":\"malo.legoff@datadoghq.com\"},\"defaultRule\":false,\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"name\":\"my_agent_rule\",\"updateDate\":1709907542607,\"updater\":{\"name\":\"Malo Le Goff\",\"handle\":\"malo.legoff@datadoghq.com\"}}}}", + "string": "{\"data\":{\"id\":\"kll-o34-int\",\"type\":\"agent_rule\",\"attributes\":{\"category\":\"Process Activity\",\"creationDate\":1711634268228,\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"defaultRule\":false,\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"name\":\"testcreateacsmthreatsagentrulereturnsokresponse1711634268\",\"updateDate\":1711634268228,\"updater\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "OK" } }, - "recorded_at": "Fri, 08 Mar 2024 14:19:02 GMT" + "recorded_at": "Thu, 28 Mar 2024 13:57:48 GMT" }, { "request": { @@ -43,7 +43,7 @@ ] }, "method": "delete", - "uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/zer-ow9-d4q" + "uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/kll-o34-int" }, "response": { "body": { @@ -60,7 +60,7 @@ "message": "No Content" } }, - "recorded_at": "Fri, 08 Mar 2024 14:19:02 GMT" + "recorded_at": "Thu, 28 Mar 2024 13:57:48 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/features/v2/cloud_workload_security.feature b/tests/scenarios/features/v2/cloud_workload_security.feature index 338b440b4..20e864078 100644 --- a/tests/scenarios/features/v2/cloud_workload_security.feature +++ b/tests/scenarios/features/v2/cloud_workload_security.feature @@ -13,7 +13,7 @@ Feature: Cloud Workload Security @team:DataDog/k9-cloud-security-platform @team:DataDog/k9-cws-backend Scenario: Create a CSM Threats Agent rule returns "Bad Request" response Given new "CreateCSMThreatsAgentRule" request - And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == sh", "name": "my_agent_rule"}, "type": "agent_rule"}} + And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == sh", "name": "{{ unique_lower_alnum }}"}, "type": "agent_rule"}} When the request is sent Then the response status is 400 Bad Request @@ -27,7 +27,7 @@ Feature: Cloud Workload Security @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": "my_agent_rule"}, "type": "agent_rule"}} + And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\"", "name": "{{ unique_lower_alnum }}"}, "type": "agent_rule"}} When the request is sent Then the response status is 200 OK