Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-05-22 20:06:38.219176",
"spec_repo_commit": "94c7d978"
"regenerated": "2024-05-23 10:59:57.755171",
"spec_repo_commit": "b829bfa2"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-05-22 20:06:38.237276",
"spec_repo_commit": "94c7d978"
"regenerated": "2024-05-23 10:59:57.776683",
"spec_repo_commit": "b829bfa2"
}
}
}
5 changes: 5 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/v2_csm-threats_create_csm_threats_agent_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ async fn main() {
"examplecsmthreat".to_string(),
)
.description("My Agent rule".to_string())
.enabled(true),
.enabled(true)
.filters(vec![r#"os == "linux""#.to_string()]),
CloudWorkloadSecurityAgentRuleType::AGENT_RULE,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub struct CloudWorkloadSecurityAgentRuleCreateAttributes {
/// The SECL expression of the Agent rule.
#[serde(rename = "expression")]
pub expression: String,
/// The platforms the Agent rule is supported on.
#[serde(rename = "filters")]
pub filters: Option<Vec<String>>,
/// The name of the Agent rule.
#[serde(rename = "name")]
pub name: String,
Expand All @@ -34,6 +37,7 @@ impl CloudWorkloadSecurityAgentRuleCreateAttributes {
description: None,
enabled: None,
expression,
filters: None,
name,
_unparsed: false,
}
Expand All @@ -48,6 +52,11 @@ impl CloudWorkloadSecurityAgentRuleCreateAttributes {
self.enabled = Some(value);
self
}

pub fn filters(mut self, value: Vec<String>) -> Self {
self.filters = Some(value);
self
}
}

impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleCreateAttributes {
Expand All @@ -70,6 +79,7 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleCreateAttributes {
let mut description: Option<String> = None;
let mut enabled: Option<bool> = None;
let mut expression: Option<String> = None;
let mut filters: Option<Vec<String>> = None;
let mut name: Option<String> = None;
let mut _unparsed = false;

Expand All @@ -91,6 +101,12 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleCreateAttributes {
"expression" => {
expression = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"filters" => {
if v.is_null() {
continue;
}
filters = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"name" => {
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
Expand All @@ -104,6 +120,7 @@ impl<'de> Deserialize<'de> for CloudWorkloadSecurityAgentRuleCreateAttributes {
description,
enabled,
expression,
filters,
name,
_unparsed,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-23T17:57:44.371Z
2024-05-22T16:22:22.200Z
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"name\":\"testcreateacsmthreatsagentrulereturnsokresponse1713895064\"},\"type\":\"agent_rule\"}}",
"string": "{\"data\":{\"attributes\":{\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"name\":\"testcreateacsmthreatsagentrulereturnsokresponse1716394942\"},\"type\":\"agent_rule\"}}",
"encoding": null
},
"headers": {
Expand All @@ -19,7 +19,7 @@
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"922-a60-32v\",\"type\":\"agent_rule\",\"attributes\":{\"category\":\"Process Activity\",\"creationDate\":1713895064438,\"creator\":{\"name\":\"\",\"handle\":\"[email protected]\"},\"defaultRule\":false,\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"name\":\"testcreateacsmthreatsagentrulereturnsokresponse1713895064\",\"updateDate\":1713895064438,\"updater\":{\"name\":\"\",\"handle\":\"[email protected]\"}}}}",
"string": "{\"data\":{\"id\":\"pn4-mo8-u5r\",\"type\":\"agent_rule\",\"attributes\":{\"category\":\"Process Activity\",\"creationDate\":1716394942614,\"creator\":{\"name\":\"\",\"handle\":\"[email protected]\"},\"defaultRule\":false,\"description\":\"My Agent rule\",\"enabled\":true,\"expression\":\"exec.file.name == \\\"sh\\\"\",\"filters\":[\"os == \\\"linux\\\"\"],\"name\":\"testcreateacsmthreatsagentrulereturnsokresponse1716394942\",\"updateDate\":1716394942614,\"updater\":{\"name\":\"\",\"handle\":\"[email protected]\"}}}}",
"encoding": null
},
"headers": {
Expand All @@ -32,7 +32,7 @@
"message": "OK"
}
},
"recorded_at": "Tue, 23 Apr 2024 17:57:44 GMT"
"recorded_at": "Wed, 22 May 2024 16:22:22 GMT"
},
{
"request": {
Expand All @@ -43,7 +43,7 @@
]
},
"method": "delete",
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/922-a60-32v"
"uri": "https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/pn4-mo8-u5r"
},
"response": {
"body": {
Expand All @@ -60,7 +60,7 @@
"message": "No Content"
}
},
"recorded_at": "Tue, 23 Apr 2024 17:57:44 GMT"
"recorded_at": "Wed, 22 May 2024 16:22:22 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/features/v2/csm_threats.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down