Skip to content

Commit 9ec0827

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add hash field to actions in CWS agent rules (#715)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent b8d8432 commit 9ec0827

14 files changed

+91
-64
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-06-17 18:21:57.470118",
8-
"spec_repo_commit": "b1a1c000"
7+
"regenerated": "2025-06-18 09:42:16.562257",
8+
"spec_repo_commit": "b6151f30"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-06-17 18:21:57.486359",
13-
"spec_repo_commit": "b1a1c000"
12+
"regenerated": "2025-06-18 09:42:16.580922",
13+
"spec_repo_commit": "b6151f30"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7540,13 +7540,19 @@ components:
75407540
description: SECL expression used to target the container to apply the action
75417541
on
75427542
type: string
7543+
hash:
7544+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActionHash'
75437545
kill:
75447546
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleKill'
75457547
metadata:
75467548
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActionMetadata'
75477549
set:
75487550
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActionSet'
75497551
type: object
7552+
CloudWorkloadSecurityAgentRuleActionHash:
7553+
additionalProperties: {}
7554+
description: An empty object indicating the hash action
7555+
type: object
75507556
CloudWorkloadSecurityAgentRuleActionMetadata:
75517557
description: The metadata action applied on the scope matching the rule
75527558
properties:

examples/v2_csm-threats_CreateCSMThreatsAgentRule_1295653933.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateAt
77
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateData;
88
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateRequest;
99
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleType;
10+
use std::collections::BTreeMap;
1011

1112
#[tokio::main]
1213
async fn main() {
@@ -18,12 +19,15 @@ async fn main() {
1819
r#"exec.file.name == "sh""#.to_string(),
1920
"examplecsmthreat".to_string(),
2021
)
21-
.actions(Some(vec![CloudWorkloadSecurityAgentRuleAction::new().set(
22-
CloudWorkloadSecurityAgentRuleActionSet::new()
23-
.name("test_set".to_string())
24-
.scope("process".to_string())
25-
.value("test_value".to_string()),
26-
)]))
22+
.actions(Some(vec![
23+
CloudWorkloadSecurityAgentRuleAction::new().set(
24+
CloudWorkloadSecurityAgentRuleActionSet::new()
25+
.name("test_set".to_string())
26+
.scope("process".to_string())
27+
.value("test_value".to_string()),
28+
),
29+
CloudWorkloadSecurityAgentRuleAction::new().hash(BTreeMap::from([])),
30+
]))
2731
.description("My Agent rule with set action".to_string())
2832
.enabled(true)
2933
.filters(vec![])

src/datadogV2/model/model_cloud_workload_security_agent_rule_action.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub struct CloudWorkloadSecurityAgentRuleAction {
1414
/// SECL expression used to target the container to apply the action on
1515
#[serde(rename = "filter")]
1616
pub filter: Option<String>,
17+
/// An empty object indicating the hash action
18+
#[serde(rename = "hash")]
19+
pub hash: Option<std::collections::BTreeMap<String, serde_json::Value>>,
1720
/// Kill system call applied on the container matching the rule
1821
#[serde(rename = "kill")]
1922
pub kill: Option<crate::datadogV2::model::CloudWorkloadSecurityAgentRuleKill>,
@@ -34,6 +37,7 @@ impl CloudWorkloadSecurityAgentRuleAction {
3437
pub fn new() -> CloudWorkloadSecurityAgentRuleAction {
3538
CloudWorkloadSecurityAgentRuleAction {
3639
filter: None,
40+
hash: None,
3741
kill: None,
3842
metadata: None,
3943
set: None,
@@ -47,6 +51,11 @@ impl CloudWorkloadSecurityAgentRuleAction {
4751
self
4852
}
4953

54+
pub fn hash(mut self, value: std::collections::BTreeMap<String, serde_json::Value>) -> Self {
55+
self.hash = Some(value);
56+
self
57+
}
58+
5059
pub fn kill(
5160
mut self,
5261
value: crate::datadogV2::model::CloudWorkloadSecurityAgentRuleKill,
@@ -104,6 +113,7 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleAction {
104113
M: MapAccess<'a>,
105114
{
106115
let mut filter: Option<String> = None;
116+
let mut hash: Option<std::collections::BTreeMap<String, serde_json::Value>> = None;
107117
let mut kill: Option<crate::datadogV2::model::CloudWorkloadSecurityAgentRuleKill> =
108118
None;
109119
let mut metadata: Option<
@@ -126,6 +136,12 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleAction {
126136
}
127137
filter = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
128138
}
139+
"hash" => {
140+
if v.is_null() {
141+
continue;
142+
}
143+
hash = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
144+
}
129145
"kill" => {
130146
if v.is_null() {
131147
continue;
@@ -154,6 +170,7 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleAction {
154170

155171
let content = CloudWorkloadSecurityAgentRuleAction {
156172
filter,
173+
hash,
157174
kill,
158175
metadata,
159176
set,
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-05-27T10:24:57.049Z
1+
2025-06-13T15:16:58.034Z

tests/scenarios/cassettes/v2/csm_threats/Create-a-Workload-Protection-agent-rule-with-set-action-returns-OK-response.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"request": {
55
"body": {
6-
"string": "{\"data\":{\"attributes\":{\"description\":\"My agent policy\",\"enabled\":true,\"hostTags\":[\"env:staging\"],\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1748341497\"},\"type\":\"policy\"}}",
6+
"string": "{\"data\":{\"attributes\":{\"description\":\"My agent policy\",\"enabled\":true,\"hostTags\":[\"env:staging\"],\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1749827818\"},\"type\":\"policy\"}}",
77
"encoding": null
88
},
99
"headers": {
@@ -19,7 +19,7 @@
1919
},
2020
"response": {
2121
"body": {
22-
"string": "{\"data\":{\"id\":\"qyj-iza-vbu\",\"type\":\"policy\",\"attributes\":{\"blockingRulesCount\":0,\"datadogManaged\":false,\"description\":\"My agent policy\",\"disabledRulesCount\":1,\"enabled\":true,\"hostTags\":[\"env:staging\"],\"monitoringRulesCount\":225,\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1748341497\",\"policyVersion\":\"1\",\"priority\":1000000011,\"ruleCount\":226,\"updateDate\":1748341497346,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
22+
"string": "{\"data\":{\"id\":\"alt-4q4-baa\",\"type\":\"policy\",\"attributes\":{\"blockingRulesCount\":0,\"datadogManaged\":false,\"description\":\"My agent policy\",\"disabledRulesCount\":1,\"enabled\":true,\"hostTags\":[\"env:staging\"],\"monitoringRulesCount\":225,\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1749827818\",\"policyVersion\":\"1\",\"priority\":1000000013,\"ruleCount\":226,\"updateDate\":1749827818428,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
2323
"encoding": null
2424
},
2525
"headers": {
@@ -32,12 +32,12 @@
3232
"message": "OK"
3333
}
3434
},
35-
"recorded_at": "Tue, 27 May 2025 10:24:57 GMT"
35+
"recorded_at": "Fri, 13 Jun 2025 15:16:58 GMT"
3636
},
3737
{
3838
"request": {
3939
"body": {
40-
"string": "{\"data\":{\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"scope\":\"process\",\"value\":\"test_value\"}}],\"description\":\"My Agent rule with set action\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[],\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1748341497\",\"policy_id\":\"qyj-iza-vbu\",\"product_tags\":[]},\"type\":\"agent_rule\"}}",
40+
"string": "{\"data\":{\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"scope\":\"process\",\"value\":\"test_value\"}},{\"hash\":{}}],\"description\":\"My Agent rule with set action\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[],\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1749827818\",\"policy_id\":\"alt-4q4-baa\",\"product_tags\":[]},\"type\":\"agent_rule\"}}",
4141
"encoding": null
4242
},
4343
"headers": {
@@ -53,7 +53,7 @@
5353
},
5454
"response": {
5555
"body": {
56-
"string": "{\"data\":{\"id\":\"zux-bp8-zov\",\"type\":\"agent_rule\",\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"value\":\"test_value\",\"scope\":\"process\"},\"disabled\":false}],\"category\":\"Process Activity\",\"creationDate\":1748341498175,\"creator\":{\"name\":\"frog\",\"handle\":\"[email protected]\"},\"defaultRule\":false,\"description\":\"My Agent rule with set action\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"monitoring\":[\"qyj-iza-vbu\"],\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1748341497\",\"product_tags\":[],\"updateDate\":1748341498175,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
56+
"string": "{\"data\":{\"id\":\"ps3-64e-shx\",\"type\":\"agent_rule\",\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"value\":\"test_value\",\"scope\":\"process\"},\"disabled\":false},{\"hash\":{},\"disabled\":false}],\"category\":\"Process Activity\",\"creationDate\":1749827819065,\"creator\":{\"name\":\"frog\",\"handle\":\"[email protected]\"},\"defaultRule\":false,\"description\":\"My Agent rule with set action\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"monitoring\":[\"alt-4q4-baa\"],\"name\":\"testcreateaworkloadprotectionagentrulewithsetactionreturnsokresponse1749827818\",\"product_tags\":[],\"updateDate\":1749827819065,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
5757
"encoding": null
5858
},
5959
"headers": {
@@ -66,7 +66,7 @@
6666
"message": "OK"
6767
}
6868
},
69-
"recorded_at": "Tue, 27 May 2025 10:24:57 GMT"
69+
"recorded_at": "Fri, 13 Jun 2025 15:16:58 GMT"
7070
},
7171
{
7272
"request": {
@@ -77,7 +77,7 @@
7777
]
7878
},
7979
"method": "delete",
80-
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/zux-bp8-zov"
80+
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/ps3-64e-shx"
8181
},
8282
"response": {
8383
"body": {
@@ -94,7 +94,7 @@
9494
"message": "No Content"
9595
}
9696
},
97-
"recorded_at": "Tue, 27 May 2025 10:24:57 GMT"
97+
"recorded_at": "Fri, 13 Jun 2025 15:16:58 GMT"
9898
},
9999
{
100100
"request": {
@@ -105,7 +105,7 @@
105105
]
106106
},
107107
"method": "delete",
108-
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/policy/qyj-iza-vbu"
108+
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/policy/alt-4q4-baa"
109109
},
110110
"response": {
111111
"body": {
@@ -122,7 +122,7 @@
122122
"message": "No Content"
123123
}
124124
},
125-
"recorded_at": "Tue, 27 May 2025 10:24:57 GMT"
125+
"recorded_at": "Fri, 13 Jun 2025 15:16:58 GMT"
126126
}
127127
],
128128
"recorded_with": "VCR 6.0.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-05-27T10:25:02.351Z
1+
2025-06-13T15:16:43.100Z

tests/scenarios/cassettes/v2/csm_threats/Delete-a-Workload-Protection-agent-rule-returns-OK-response.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"request": {
55
"body": {
6-
"string": "{\"data\":{\"attributes\":{\"description\":\"My agent policy\",\"enabled\":true,\"hostTags\":[\"env:staging\"],\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1748341502\"},\"type\":\"policy\"}}",
6+
"string": "{\"data\":{\"attributes\":{\"description\":\"My agent policy\",\"enabled\":true,\"hostTags\":[\"env:staging\"],\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1749827803\"},\"type\":\"policy\"}}",
77
"encoding": null
88
},
99
"headers": {
@@ -19,7 +19,7 @@
1919
},
2020
"response": {
2121
"body": {
22-
"string": "{\"data\":{\"id\":\"ney-zeu-tex\",\"type\":\"policy\",\"attributes\":{\"blockingRulesCount\":0,\"datadogManaged\":false,\"description\":\"My agent policy\",\"disabledRulesCount\":1,\"enabled\":true,\"hostTags\":[\"env:staging\"],\"monitoringRulesCount\":225,\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1748341502\",\"policyVersion\":\"1\",\"priority\":1000000011,\"ruleCount\":226,\"updateDate\":1748341502642,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
22+
"string": "{\"data\":{\"id\":\"tn0-tjy-vwh\",\"type\":\"policy\",\"attributes\":{\"blockingRulesCount\":0,\"datadogManaged\":false,\"description\":\"My agent policy\",\"disabledRulesCount\":1,\"enabled\":true,\"hostTags\":[\"env:staging\"],\"monitoringRulesCount\":225,\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1749827803\",\"policyVersion\":\"1\",\"priority\":1000000013,\"ruleCount\":226,\"updateDate\":1749827803539,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
2323
"encoding": null
2424
},
2525
"headers": {
@@ -32,12 +32,12 @@
3232
"message": "OK"
3333
}
3434
},
35-
"recorded_at": "Tue, 27 May 2025 10:25:02 GMT"
35+
"recorded_at": "Fri, 13 Jun 2025 15:16:43 GMT"
3636
},
3737
{
3838
"request": {
3939
"body": {
40-
"string": "{\"data\":{\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"scope\":\"process\",\"value\":\"test_value\"}}],\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1748341502\",\"policy_id\":\"ney-zeu-tex\",\"product_tags\":[\"security:attack\",\"technique:T1059\"]},\"type\":\"agent_rule\"}}",
40+
"string": "{\"data\":{\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"scope\":\"process\",\"value\":\"test_value\"}},{\"hash\":{}}],\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1749827803\",\"policy_id\":\"tn0-tjy-vwh\",\"product_tags\":[\"security:attack\",\"technique:T1059\"]},\"type\":\"agent_rule\"}}",
4141
"encoding": null
4242
},
4343
"headers": {
@@ -53,7 +53,7 @@
5353
},
5454
"response": {
5555
"body": {
56-
"string": "{\"data\":{\"id\":\"gys-bzk-zs4\",\"type\":\"agent_rule\",\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"value\":\"test_value\",\"scope\":\"process\"},\"disabled\":false}],\"category\":\"Process Activity\",\"creationDate\":1748341503254,\"creator\":{\"name\":\"frog\",\"handle\":\"[email protected]\"},\"defaultRule\":false,\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"monitoring\":[\"ney-zeu-tex\"],\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1748341502\",\"product_tags\":[\"security:attack\",\"technique:T1059\"],\"updateDate\":1748341503254,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
56+
"string": "{\"data\":{\"id\":\"hm0-n7p-hq7\",\"type\":\"agent_rule\",\"attributes\":{\"actions\":[{\"set\":{\"name\":\"test_set\",\"value\":\"test_value\",\"scope\":\"process\"},\"disabled\":false},{\"hash\":{},\"disabled\":false}],\"category\":\"Process Activity\",\"creationDate\":1749827804150,\"creator\":{\"name\":\"frog\",\"handle\":\"[email protected]\"},\"defaultRule\":false,\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"monitoring\":[\"tn0-tjy-vwh\"],\"name\":\"testdeleteaworkloadprotectionagentrulereturnsokresponse1749827803\",\"product_tags\":[\"security:attack\",\"technique:T1059\"],\"updateDate\":1749827804150,\"updater\":{\"name\":\"frog\",\"handle\":\"[email protected]\"}}}}",
5757
"encoding": null
5858
},
5959
"headers": {
@@ -66,7 +66,7 @@
6666
"message": "OK"
6767
}
6868
},
69-
"recorded_at": "Tue, 27 May 2025 10:25:02 GMT"
69+
"recorded_at": "Fri, 13 Jun 2025 15:16:43 GMT"
7070
},
7171
{
7272
"request": {
@@ -77,7 +77,7 @@
7777
]
7878
},
7979
"method": "delete",
80-
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/gys-bzk-zs4?policy_id=ney-zeu-tex"
80+
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/hm0-n7p-hq7?policy_id=tn0-tjy-vwh"
8181
},
8282
"response": {
8383
"body": {
@@ -94,7 +94,7 @@
9494
"message": "No Content"
9595
}
9696
},
97-
"recorded_at": "Tue, 27 May 2025 10:25:02 GMT"
97+
"recorded_at": "Fri, 13 Jun 2025 15:16:43 GMT"
9898
},
9999
{
100100
"request": {
@@ -105,7 +105,7 @@
105105
]
106106
},
107107
"method": "delete",
108-
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/gys-bzk-zs4"
108+
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/hm0-n7p-hq7"
109109
},
110110
"response": {
111111
"body": {
@@ -122,7 +122,7 @@
122122
"message": "Not Found"
123123
}
124124
},
125-
"recorded_at": "Tue, 27 May 2025 10:25:02 GMT"
125+
"recorded_at": "Fri, 13 Jun 2025 15:16:43 GMT"
126126
},
127127
{
128128
"request": {
@@ -133,7 +133,7 @@
133133
]
134134
},
135135
"method": "delete",
136-
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/policy/ney-zeu-tex"
136+
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/policy/tn0-tjy-vwh"
137137
},
138138
"response": {
139139
"body": {
@@ -150,7 +150,7 @@
150150
"message": "No Content"
151151
}
152152
},
153-
"recorded_at": "Tue, 27 May 2025 10:25:02 GMT"
153+
"recorded_at": "Fri, 13 Jun 2025 15:16:43 GMT"
154154
}
155155
],
156156
"recorded_with": "VCR 6.0.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-05-27T10:25:11.236Z
1+
2025-06-13T15:16:09.321Z

0 commit comments

Comments
 (0)