Skip to content

Commit b0d5e30

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

File tree

60 files changed

+5817
-4219
lines changed

Some content is hidden

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

60 files changed

+5817
-4219
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.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"env:test",
2626
],
2727
],
28-
name="my_agent_policy",
28+
name="my_agent_policy_2",
2929
),
3030
type=CloudWorkloadSecurityAgentPolicyType.POLICY,
3131
),

examples/v2/csm-threats/CreateCSMThreatsAgentRule.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
description="My Agent rule",
2626
enabled=True,
2727
expression='exec.file.name == "sh"',
28+
agent_version="> 7.60",
2829
filters=[],
2930
name="examplecsmthreat",
3031
policy_id=POLICY_DATA_ID,

examples/v2/csm-threats/CreateCSMThreatsAgentRule_1295653933.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
name="test_set",
4343
value="test_value",
4444
scope="process",
45+
inherited=True,
4546
),
4647
),
4748
CloudWorkloadSecurityAgentRuleAction(
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
Create a Workload Protection agent rule with set action with expression returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.csm_threats_api import CSMThreatsApi
8+
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_action import CloudWorkloadSecurityAgentRuleAction
9+
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_action_set import (
10+
CloudWorkloadSecurityAgentRuleActionSet,
11+
)
12+
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_attributes import (
13+
CloudWorkloadSecurityAgentRuleCreateAttributes,
14+
)
15+
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_data import (
16+
CloudWorkloadSecurityAgentRuleCreateData,
17+
)
18+
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_request import (
19+
CloudWorkloadSecurityAgentRuleCreateRequest,
20+
)
21+
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_type import CloudWorkloadSecurityAgentRuleType
22+
23+
# there is a valid "policy_rc" in the system
24+
POLICY_DATA_ID = environ["POLICY_DATA_ID"]
25+
26+
body = CloudWorkloadSecurityAgentRuleCreateRequest(
27+
data=CloudWorkloadSecurityAgentRuleCreateData(
28+
attributes=CloudWorkloadSecurityAgentRuleCreateAttributes(
29+
description="My Agent rule with set action with expression",
30+
enabled=True,
31+
expression='exec.file.name == "sh"',
32+
filters=[],
33+
name="examplecsmthreat",
34+
policy_id=POLICY_DATA_ID,
35+
product_tags=[],
36+
actions=[
37+
CloudWorkloadSecurityAgentRuleAction(
38+
set=CloudWorkloadSecurityAgentRuleActionSet(
39+
name="test_set",
40+
expression="open.file.path",
41+
default_value="/dev/null",
42+
scope="process",
43+
),
44+
),
45+
],
46+
),
47+
type=CloudWorkloadSecurityAgentRuleType.AGENT_RULE,
48+
),
49+
)
50+
51+
configuration = Configuration()
52+
with ApiClient(configuration) as api_client:
53+
api_instance = CSMThreatsApi(api_client)
54+
response = api_instance.create_csm_threats_agent_rule(body=body)
55+
56+
print(response)

src/datadog_api_client/v2/model/cloud_workload_security_agent_policy_attributes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from datadog_api_client.v2.model.cloud_workload_security_agent_policy_updater_attributes import (
1818
CloudWorkloadSecurityAgentPolicyUpdaterAttributes,
1919
)
20+
from datadog_api_client.v2.model.cloud_workload_security_agent_policy_version import (
21+
CloudWorkloadSecurityAgentPolicyVersion,
22+
)
2023

2124

2225
class CloudWorkloadSecurityAgentPolicyAttributes(ModelNormal):
@@ -40,6 +43,9 @@ def openapi_types(_):
4043
from datadog_api_client.v2.model.cloud_workload_security_agent_policy_updater_attributes import (
4144
CloudWorkloadSecurityAgentPolicyUpdaterAttributes,
4245
)
46+
from datadog_api_client.v2.model.cloud_workload_security_agent_policy_version import (
47+
CloudWorkloadSecurityAgentPolicyVersion,
48+
)
4349

4450
return {
4551
"blocking_rules_count": (int,),
@@ -51,12 +57,14 @@ def openapi_types(_):
5157
"host_tags_lists": ([[str]],),
5258
"monitoring_rules_count": (int,),
5359
"name": (str,),
60+
"pinned": (bool,),
5461
"policy_version": (str,),
5562
"priority": (int,),
5663
"rule_count": (int,),
5764
"update_date": (int,),
5865
"updated_at": (int,),
5966
"updater": (CloudWorkloadSecurityAgentPolicyUpdaterAttributes,),
67+
"versions": ([CloudWorkloadSecurityAgentPolicyVersion],),
6068
}
6169

6270
attribute_map = {
@@ -69,12 +77,14 @@ def openapi_types(_):
6977
"host_tags_lists": "hostTagsLists",
7078
"monitoring_rules_count": "monitoringRulesCount",
7179
"name": "name",
80+
"pinned": "pinned",
7281
"policy_version": "policyVersion",
7382
"priority": "priority",
7483
"rule_count": "ruleCount",
7584
"update_date": "updateDate",
7685
"updated_at": "updatedAt",
7786
"updater": "updater",
87+
"versions": "versions",
7888
}
7989

8090
def __init__(
@@ -88,12 +98,14 @@ def __init__(
8898
host_tags_lists: Union[List[List[str]], UnsetType] = unset,
8999
monitoring_rules_count: Union[int, UnsetType] = unset,
90100
name: Union[str, UnsetType] = unset,
101+
pinned: Union[bool, UnsetType] = unset,
91102
policy_version: Union[str, UnsetType] = unset,
92103
priority: Union[int, UnsetType] = unset,
93104
rule_count: Union[int, UnsetType] = unset,
94105
update_date: Union[int, UnsetType] = unset,
95106
updated_at: Union[int, UnsetType] = unset,
96107
updater: Union[CloudWorkloadSecurityAgentPolicyUpdaterAttributes, UnsetType] = unset,
108+
versions: Union[List[CloudWorkloadSecurityAgentPolicyVersion], UnsetType] = unset,
97109
**kwargs,
98110
):
99111
"""
@@ -126,6 +138,9 @@ def __init__(
126138
:param name: The name of the policy
127139
:type name: str, optional
128140
141+
:param pinned: Whether the policy is pinned
142+
:type pinned: bool, optional
143+
129144
:param policy_version: The version of the policy
130145
:type policy_version: str, optional
131146
@@ -143,6 +158,9 @@ def __init__(
143158
144159
:param updater: The attributes of the user who last updated the policy
145160
:type updater: CloudWorkloadSecurityAgentPolicyUpdaterAttributes, optional
161+
162+
:param versions: The versions of the policy
163+
:type versions: [CloudWorkloadSecurityAgentPolicyVersion], optional
146164
"""
147165
if blocking_rules_count is not unset:
148166
kwargs["blocking_rules_count"] = blocking_rules_count
@@ -162,6 +180,8 @@ def __init__(
162180
kwargs["monitoring_rules_count"] = monitoring_rules_count
163181
if name is not unset:
164182
kwargs["name"] = name
183+
if pinned is not unset:
184+
kwargs["pinned"] = pinned
165185
if policy_version is not unset:
166186
kwargs["policy_version"] = policy_version
167187
if priority is not unset:
@@ -174,4 +194,6 @@ def __init__(
174194
kwargs["updated_at"] = updated_at
175195
if updater is not unset:
176196
kwargs["updater"] = updater
197+
if versions is not unset:
198+
kwargs["versions"] = versions
177199
super().__init__(kwargs)

0 commit comments

Comments
 (0)