Skip to content

Commit 3151a04

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add some missing Workload Protection agent rule fields (#3161)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 441c610 commit 3151a04

File tree

59 files changed

+903
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+903
-190
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9472,6 +9472,10 @@ components:
94729472
description: The name of the policy
94739473
example: my_agent_policy
94749474
type: string
9475+
pinned:
9476+
description: Whether the policy is pinned
9477+
example: false
9478+
type: boolean
94759479
policyVersion:
94769480
description: The version of the policy
94779481
example: '1'
@@ -9499,6 +9503,8 @@ components:
94999503
type: integer
95009504
updater:
95019505
$ref: '#/components/schemas/CloudWorkloadSecurityAgentPolicyUpdaterAttributes'
9506+
versions:
9507+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentPolicyVersions'
95029508
type: object
95039509
CloudWorkloadSecurityAgentPolicyCreateAttributes:
95049510
description: Create a new Cloud Workload Security Agent policy
@@ -9645,6 +9651,23 @@ components:
96459651
nullable: true
96469652
type: string
96479653
type: object
9654+
CloudWorkloadSecurityAgentPolicyVersion:
9655+
description: The versions of the policy
9656+
properties:
9657+
Date:
9658+
description: The date and time the version was created
9659+
nullable: true
9660+
type: string
9661+
Name:
9662+
description: The version of the policy
9663+
example: 1.47.0-rc2
9664+
type: string
9665+
type: object
9666+
CloudWorkloadSecurityAgentPolicyVersions:
9667+
description: The versions of the policy
9668+
items:
9669+
$ref: '#/components/schemas/CloudWorkloadSecurityAgentPolicyVersion'
9670+
type: array
96489671
CloudWorkloadSecurityAgentRuleAction:
96499672
description: The action the rule can perform if triggered
96509673
properties:
@@ -9682,23 +9705,32 @@ components:
96829705
description: The set action applied on the scope matching the rule
96839706
properties:
96849707
append:
9685-
description: Whether the value should be appended to the field
9708+
description: Whether the value should be appended to the field.
96869709
type: boolean
9710+
default_value:
9711+
description: The default value of the set action
9712+
type: string
9713+
expression:
9714+
description: The expression of the set action.
9715+
type: string
96879716
field:
96889717
description: The field of the set action
96899718
type: string
9719+
inherited:
9720+
description: Whether the value should be inherited.
9721+
type: boolean
96909722
name:
96919723
description: The name of the set action
96929724
type: string
96939725
scope:
9694-
description: The scope of the set action
9726+
description: The scope of the set action.
96959727
type: string
96969728
size:
9697-
description: The size of the set action
9729+
description: The size of the set action.
96989730
format: int64
96999731
type: integer
97009732
ttl:
9701-
description: The time to live of the set action
9733+
description: The time to live of the set action.
97029734
format: int64
97039735
type: integer
97049736
value:
@@ -9779,6 +9811,10 @@ components:
97799811
items:
97809812
type: string
97819813
type: array
9814+
silent:
9815+
description: Whether the rule is silent.
9816+
example: false
9817+
type: boolean
97829818
updateAuthorUuId:
97839819
description: The ID of the user who updated the rule
97849820
example: e51c9744-d158-11ec-ad23-da7ad0900002
@@ -9806,8 +9842,11 @@ components:
98069842
properties:
98079843
actions:
98089844
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActions'
9845+
agent_version:
9846+
description: Constrain the rule to specific versions of the Datadog Agent.
9847+
type: string
98099848
blocking:
9810-
description: The blocking policies that the rule belongs to
9849+
description: The blocking policies that the rule belongs to.
98119850
items:
98129851
type: string
98139852
type: array
@@ -9816,25 +9855,25 @@ components:
98169855
example: My Agent rule
98179856
type: string
98189857
disabled:
9819-
description: The disabled policies that the rule belongs to
9858+
description: The disabled policies that the rule belongs to.
98209859
items:
98219860
type: string
98229861
type: array
98239862
enabled:
9824-
description: Whether the Agent rule is enabled
9863+
description: Whether the Agent rule is enabled.
98259864
example: true
98269865
type: boolean
98279866
expression:
98289867
description: The SECL expression of the Agent rule.
98299868
example: exec.file.name == "sh"
98309869
type: string
98319870
filters:
9832-
description: The platforms the Agent rule is supported on
9871+
description: The platforms the Agent rule is supported on.
98339872
items:
98349873
type: string
98359874
type: array
98369875
monitoring:
9837-
description: The monitoring policies that the rule belongs to
9876+
description: The monitoring policies that the rule belongs to.
98389877
items:
98399878
type: string
98409879
type: array
@@ -9843,14 +9882,18 @@ components:
98439882
example: my_agent_rule
98449883
type: string
98459884
policy_id:
9846-
description: The ID of the policy where the Agent rule is saved
9885+
description: The ID of the policy where the Agent rule is saved.
98479886
example: a8c8e364-6556-434d-b798-a4c23de29c0b
98489887
type: string
98499888
product_tags:
9850-
description: The list of product tags associated with the rule
9889+
description: The list of product tags associated with the rule.
98519890
items:
98529891
type: string
98539892
type: array
9893+
silent:
9894+
description: Whether the rule is silent.
9895+
example: false
9896+
type: boolean
98549897
required:
98559898
- name
98569899
- expression
@@ -9930,6 +9973,9 @@ components:
99309973
properties:
99319974
actions:
99329975
$ref: '#/components/schemas/CloudWorkloadSecurityAgentRuleActions'
9976+
agent_version:
9977+
description: Constrain the rule to specific versions of the Datadog Agent
9978+
type: string
99339979
blocking:
99349980
description: The blocking policies that the rule belongs to
99359981
items:
@@ -9966,6 +10012,10 @@ components:
996610012
items:
996710013
type: string
996810014
type: array
10015+
silent:
10016+
description: Whether the rule is silent.
10017+
example: false
10018+
type: boolean
996910019
type: object
997010020
CloudWorkloadSecurityAgentRuleUpdateData:
997110021
description: Object for a single Agent rule

examples/v2/csm-threats/CreateCSMThreatsAgentPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args) {
2525
.enabled(true)
2626
.hostTagsLists(
2727
Collections.singletonList(Collections.singletonList("env:test")))
28-
.name("my_agent_policy"))
28+
.name("my_agent_policy_2"))
2929
.type(CloudWorkloadSecurityAgentPolicyType.POLICY));
3030

3131
try {

examples/v2/csm-threats/CreateCSMThreatsAgentRule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static void main(String[] args) {
2828
.expression("""
2929
exec.file.name == "sh"
3030
""")
31+
.agentVersion("> 7.60")
3132
.name("examplecsmthreat")
3233
.policyId(POLICY_DATA_ID))
3334
.type(CloudWorkloadSecurityAgentRuleType.AGENT_RULE));

examples/v2/csm-threats/CreateCSMThreatsAgentRule_1295653933.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public static void main(String[] args) {
4141
new CloudWorkloadSecurityAgentRuleActionSet()
4242
.name("test_set")
4343
.value("test_value")
44-
.scope("process")),
44+
.scope("process")
45+
.inherited(true)),
4546
new CloudWorkloadSecurityAgentRuleAction()
4647
.hash(Map.ofEntries()))))
4748
.type(CloudWorkloadSecurityAgentRuleType.AGENT_RULE));
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Create a Workload Protection agent rule with set action with expression returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.CsmThreatsApi;
6+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleAction;
7+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleActionSet;
8+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleCreateAttributes;
9+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleCreateData;
10+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleCreateRequest;
11+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleResponse;
12+
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleType;
13+
import java.util.Collections;
14+
15+
public class Example {
16+
public static void main(String[] args) {
17+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
18+
CsmThreatsApi apiInstance = new CsmThreatsApi(defaultClient);
19+
20+
// there is a valid "policy_rc" in the system
21+
String POLICY_DATA_ID = System.getenv("POLICY_DATA_ID");
22+
23+
CloudWorkloadSecurityAgentRuleCreateRequest body =
24+
new CloudWorkloadSecurityAgentRuleCreateRequest()
25+
.data(
26+
new CloudWorkloadSecurityAgentRuleCreateData()
27+
.attributes(
28+
new CloudWorkloadSecurityAgentRuleCreateAttributes()
29+
.description("My Agent rule with set action with expression")
30+
.enabled(true)
31+
.expression("""
32+
exec.file.name == "sh"
33+
""")
34+
.name("examplecsmthreat")
35+
.policyId(POLICY_DATA_ID)
36+
.actions(
37+
Collections.singletonList(
38+
new CloudWorkloadSecurityAgentRuleAction()
39+
.set(
40+
new CloudWorkloadSecurityAgentRuleActionSet()
41+
.name("test_set")
42+
.expression("open.file.path")
43+
.defaultValue("/dev/null")
44+
.scope("process")))))
45+
.type(CloudWorkloadSecurityAgentRuleType.AGENT_RULE));
46+
47+
try {
48+
CloudWorkloadSecurityAgentRuleResponse result = apiInstance.createCSMThreatsAgentRule(body);
49+
System.out.println(result);
50+
} catch (ApiException e) {
51+
System.err.println("Exception when calling CsmThreatsApi#createCSMThreatsAgentRule");
52+
System.err.println("Status code: " + e.getCode());
53+
System.err.println("Reason: " + e.getResponseBody());
54+
System.err.println("Response headers: " + e.getResponseHeaders());
55+
e.printStackTrace();
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)