For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/es/api/latest/static-analysis/create-custom-rule-revision.md. A documentation index is available at /llms.txt.
Language
Datadog site

Create Custom Rule Revision

ADVERTENCIAThis endpoint is in Preview and may introduce breaking changes. If you have any feedback, contact Datadog support.
PUThttps://api.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.us3.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.datadoghq.eu/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.ap1.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.ap2.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.uk1.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisionshttps://api.us2.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions

Descripción general

Create a new revision for a custom rule

Argumentos

Parámetros de ruta

Nombre
Type
Descripción
ruleset_name [required]
string

The ruleset name

rule_name [required]
string

The rule name

Solicitud

Body Data (required)

Campo
Type
Descripción
_authentication_token
string

CSRF token for security, sent by browser-based clients. Ignored by the API when absent.

data
object

Data object for a custom rule revision create request.

Respuesta

Successfully created

Ejemplo de código

# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF
# Path parameters
export ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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 PUT "https://api.${DD_SITE}/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF