Crear una regla de Agent de Workload Protection (US1-FED)
https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.us3.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.us5.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.datadoghq.eu/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.ap1.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.ap2.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.uk1.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.ddog-gov.com/api/v2/security_monitoring/cloud_workload_security/agent_ruleshttps://api.us2.ddog-gov.com/api/v2/security_monitoring/cloud_workload_security/agent_rulesDescripción general
Crea una nueva regla del Agent con los parámetros indicados.
Nota: Este endpoint sólo debe utilizarse para el sitio del Gobierno (US1-FED).
Solicitud
Body Data (required)
La definición de la nueva regla del Agent
data [required]Objeto de solicitud que incluye la regla del Agent a crear
attributes [required]Create a new Cloud Workload Security Agent rule.
actionsThe array of actions the rule can perform if triggered
coredumpThe core dump action applied on the process matching the rule.
dentryWhether the directory entry information is included in the core dump.
mountWhether the mount information is included in the core dump.
no_compressionWhether the core dump is left uncompressed.
processWhether the process memory is included in the core dump.
disabledWhether the action is disabled
filterSECL expression used to target the container to apply the action on
hashHash file specified by the field attribute
fieldThe field of the hash action
max_file_sizeThe maximum size of the files to hash, in bytes.
killKill system call applied on the container matching the rule
disable_container_disarmerWhether the automatic container safeguard of the kill action is disabled.
disable_executable_disarmerWhether the automatic executable safeguard of the kill action is disabled.
scopeThe scope of the kill action.
signalSupported signals for the kill system call
logThe log action applied when the rule is triggered.
levelThe level of the log action.
messageThe message of the log action.
metadataThe metadata action applied on the scope matching the rule
image_tagThe image tag of the metadata action
serviceThe service of the metadata action
short_imageThe short image of the metadata action
network_filterThe network filter action applied on the network traffic matching the rule.
filterThe filter expression of the network filter action.
policyThe policy of the network filter action.
scopeThe scope of the network filter action.
setThe set action applied on the scope matching the rule
appendWhether the value should be appended to the field.
default_valueThe default value of the set action
expressionThe expression of the set action.
fieldThe field of the set action
inheritedWhether the value should be inherited.
nameThe name of the set action
privateWhether the value of the set action is private.
scopeThe scope of the set action.
scope_fieldThe scope field of the set action.
sizeThe size of the set action.
ttlThe time to live of the set action.
valueThe value of the set action
Object 1Object 2Object 3agent_versionConstrain the rule to specific versions of the Datadog Agent.
blockingThe blocking policies that the rule belongs to.
descriptionThe description of the Agent rule.
disabledThe disabled policies that the rule belongs to.
enabledWhether the Agent rule is enabled.
expression [required]The SECL expression of the Agent rule.
filtersThe platforms the Agent rule is supported on.
monitoringThe monitoring policies that the rule belongs to.
name [required]The name of the Agent rule.
policy_idThe ID of the policy where the Agent rule is saved.
product_tagsThe list of product tags associated with the rule.
silentWhether the rule is silent.
type [required]The type of the resource, must always be agent_rule
agent_ruleagent_rule{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}Respuesta
OK
Response object that includes an Agent rule
dataObject for a single Agent rule
attributesA Cloud Workload Security Agent rule returned by the API
actionsThe array of actions the rule can perform if triggered
coredumpThe core dump action applied on the process matching the rule.
dentryWhether the directory entry information is included in the core dump.
mountWhether the mount information is included in the core dump.
no_compressionWhether the core dump is left uncompressed.
processWhether the process memory is included in the core dump.
disabledWhether the action is disabled
filterSECL expression used to target the container to apply the action on
hashHash file specified by the field attribute
fieldThe field of the hash action
max_file_sizeThe maximum size of the files to hash, in bytes.
killKill system call applied on the container matching the rule
disable_container_disarmerWhether the automatic container safeguard of the kill action is disabled.
disable_executable_disarmerWhether the automatic executable safeguard of the kill action is disabled.
scopeThe scope of the kill action.
signalSupported signals for the kill system call
logThe log action applied when the rule is triggered.
levelThe level of the log action.
messageThe message of the log action.
metadataThe metadata action applied on the scope matching the rule
image_tagThe image tag of the metadata action
serviceThe service of the metadata action
short_imageThe short image of the metadata action
network_filterThe network filter action applied on the network traffic matching the rule.
filterThe filter expression of the network filter action.
policyThe policy of the network filter action.
scopeThe scope of the network filter action.
setThe set action applied on the scope matching the rule
appendWhether the value should be appended to the field.
default_valueThe default value of the set action
expressionThe expression of the set action.
fieldThe field of the set action
inheritedWhether the value should be inherited.
nameThe name of the set action
privateWhether the value of the set action is private.
scopeThe scope of the set action.
scope_fieldThe scope field of the set action.
sizeThe size of the set action.
ttlThe time to live of the set action.
valueThe value of the set action
Object 1Object 2Object 3agentConstraintThe version of the Agent
agent_versionThe version constraint of the Datadog Agent the rule applies to
blockingThe blocking policies that the rule belongs to
categoryThe category of the Agent rule
creationAuthorUuIdThe ID of the user who created the rule
creationDateWhen the Agent rule was created, timestamp in milliseconds
creatorThe attributes of the user who created the Agent rule
handleThe handle of the user
nameThe name of the user
defaultRuleWhether the rule is included by default
descriptionThe description of the Agent rule
disabledThe disabled policies that the rule belongs to
enabledWhether the Agent rule is enabled
everyThe rate limiting duration of the Agent rule, in nanoseconds
expressionThe SECL expression of the Agent rule
filtersThe platforms the Agent rule is supported on
group_idThe group of rules the Agent rule belongs to
monitoringThe monitoring policies that the rule belongs to
nameThe name of the Agent rule
product_tagsThe list of product tags associated with the rule
silentWhether the rule is silent.
updateAuthorUuIdThe ID of the user who updated the rule
updateDateTimestamp in milliseconds when the Agent rule was last updated
updatedAtWhen the Agent rule was last updated, timestamp in milliseconds
updaterThe attributes of the user who last updated the Agent rule
handleThe handle of the user
nameThe name of the user
versionThe version of the Agent rule
idThe ID of the Agent rule
typeThe type of the resource, must always be agent_rule
agent_ruleagent_rule{
"data": {
"attributes": {
"actions": [
{
"coredump": {
"dentry": false,
"mount": false,
"no_compression": false,
"process": false
},
"disabled": false,
"filter": "string",
"hash": {
"field": "string",
"max_file_size": "integer"
},
"kill": {
"disable_container_disarmer": false,
"disable_executable_disarmer": false,
"scope": "string",
"signal": "string"
},
"log": {
"level": "string",
"message": "string"
},
"metadata": {
"image_tag": "string",
"service": "string",
"short_image": "string"
},
"network_filter": {
"filter": "string",
"policy": "string",
"scope": "string"
},
"set": {
"append": false,
"default_value": "string",
"expression": "string",
"field": "string",
"inherited": false,
"name": "string",
"private": false,
"scope": "string",
"scope_field": "string",
"size": "integer",
"ttl": "integer",
"value": {
"type": "undefined"
}
}
}
],
"agentConstraint": "string",
"agent_version": ">=7.62",
"blocking": [],
"category": "Process Activity",
"creationAuthorUuId": "e51c9744-d158-11ec-ad23-da7ad0900002",
"creationDate": 1624366480320,
"creator": {
"handle": "datadog.user@example.com",
"name": "Datadog User"
},
"defaultRule": false,
"description": "My Agent rule",
"disabled": [],
"enabled": true,
"every": 60000000000,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"group_id": "group_id",
"monitoring": [],
"name": "my_agent_rule",
"product_tags": [],
"silent": false,
"updateAuthorUuId": "e51c9744-d158-11ec-ad23-da7ad0900002",
"updateDate": 1624366480320,
"updatedAt": 1624366480320,
"updater": {
"handle": "datadog.user@example.com",
"name": "Datadog User"
},
"version": 23
},
"id": "3dd-0uc-h1s",
"type": "agent_rule"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Conflict
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Ejemplo de código
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/security_monitoring/cloud_workload_security/agent_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "My Agent rule",
"enabled": true,
"expression": "exec.file.name == \"sh\"",
"filters": [],
"name": "examplecsmthreat"
},
"type": "agent_rule"
}
}
EOF// Create a Workload Protection agent rule (US1-FED) returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.CloudWorkloadSecurityAgentRuleCreateRequest{
Data: datadogV2.CloudWorkloadSecurityAgentRuleCreateData{
Attributes: datadogV2.CloudWorkloadSecurityAgentRuleCreateAttributes{
Description: datadog.PtrString("My Agent rule"),
Enabled: datadog.PtrBool(true),
Expression: `exec.file.name == "sh"`,
Filters: []string{},
Name: "examplecsmthreat",
},
Type: datadogV2.CLOUDWORKLOADSECURITYAGENTRULETYPE_AGENT_RULE,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCSMThreatsApi(apiClient)
resp, r, err := api.CreateCloudWorkloadSecurityAgentRule(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CSMThreatsApi.CreateCloudWorkloadSecurityAgentRule`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CSMThreatsApi.CreateCloudWorkloadSecurityAgentRule`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create a Workload Protection agent rule (US1-FED) returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CsmThreatsApi;
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleCreateAttributes;
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleCreateData;
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleCreateRequest;
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleResponse;
import com.datadog.api.client.v2.model.CloudWorkloadSecurityAgentRuleType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
CsmThreatsApi apiInstance = new CsmThreatsApi(defaultClient);
CloudWorkloadSecurityAgentRuleCreateRequest body =
new CloudWorkloadSecurityAgentRuleCreateRequest()
.data(
new CloudWorkloadSecurityAgentRuleCreateData()
.attributes(
new CloudWorkloadSecurityAgentRuleCreateAttributes()
.description("My Agent rule")
.enabled(true)
.expression("""
exec.file.name == "sh"
""")
.name("examplecsmthreat"))
.type(CloudWorkloadSecurityAgentRuleType.AGENT_RULE));
try {
CloudWorkloadSecurityAgentRuleResponse result =
apiInstance.createCloudWorkloadSecurityAgentRule(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling CsmThreatsApi#createCloudWorkloadSecurityAgentRule");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create a Workload Protection agent rule (US1-FED) returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.csm_threats_api import CSMThreatsApi
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_attributes import (
CloudWorkloadSecurityAgentRuleCreateAttributes,
)
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_data import (
CloudWorkloadSecurityAgentRuleCreateData,
)
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_create_request import (
CloudWorkloadSecurityAgentRuleCreateRequest,
)
from datadog_api_client.v2.model.cloud_workload_security_agent_rule_type import CloudWorkloadSecurityAgentRuleType
body = CloudWorkloadSecurityAgentRuleCreateRequest(
data=CloudWorkloadSecurityAgentRuleCreateData(
attributes=CloudWorkloadSecurityAgentRuleCreateAttributes(
description="My Agent rule",
enabled=True,
expression='exec.file.name == "sh"',
filters=[],
name="examplecsmthreat",
),
type=CloudWorkloadSecurityAgentRuleType.AGENT_RULE,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CSMThreatsApi(api_client)
response = api_instance.create_cloud_workload_security_agent_rule(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create a Workload Protection agent rule (US1-FED) returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CSMThreatsAPI.new
body = DatadogAPIClient::V2::CloudWorkloadSecurityAgentRuleCreateRequest.new({
data: DatadogAPIClient::V2::CloudWorkloadSecurityAgentRuleCreateData.new({
attributes: DatadogAPIClient::V2::CloudWorkloadSecurityAgentRuleCreateAttributes.new({
description: "My Agent rule",
enabled: true,
expression: 'exec.file.name == "sh"',
filters: [],
name: "examplecsmthreat",
}),
type: DatadogAPIClient::V2::CloudWorkloadSecurityAgentRuleType::AGENT_RULE,
}),
})
p api_instance.create_cloud_workload_security_agent_rule(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create a Workload Protection agent rule (US1-FED) returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_csm_threats::CSMThreatsAPI;
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateAttributes;
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateData;
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateRequest;
use datadog_api_client::datadogV2::model::CloudWorkloadSecurityAgentRuleType;
#[tokio::main]
async fn main() {
let body = CloudWorkloadSecurityAgentRuleCreateRequest::new(
CloudWorkloadSecurityAgentRuleCreateData::new(
CloudWorkloadSecurityAgentRuleCreateAttributes::new(
r#"exec.file.name == "sh""#.to_string(),
"examplecsmthreat".to_string(),
)
.description("My Agent rule".to_string())
.enabled(true)
.filters(vec![]),
CloudWorkloadSecurityAgentRuleType::AGENT_RULE,
),
);
let configuration = datadog::Configuration::new();
let api = CSMThreatsAPI::with_config(configuration);
let resp = api.create_cloud_workload_security_agent_rule(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create a Workload Protection agent rule (US1-FED) returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.CSMThreatsApi(configuration);
const params: v2.CSMThreatsApiCreateCloudWorkloadSecurityAgentRuleRequest = {
body: {
data: {
attributes: {
description: "My Agent rule",
enabled: true,
expression: `exec.file.name == "sh"`,
filters: [],
name: "examplecsmthreat",
},
type: "agent_rule",
},
},
};
apiInstance
.createCloudWorkloadSecurityAgentRule(params)
.then((data: v2.CloudWorkloadSecurityAgentRuleResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"