Returns a list of Secrets rules

Note: This endpoint may be subject to changes.

GET https://api.ap1.datadoghq.com/api/v2/static-analysis/secrets/ruleshttps://api.ap2.datadoghq.com/api/v2/static-analysis/secrets/ruleshttps://api.datadoghq.eu/api/v2/static-analysis/secrets/ruleshttps://api.ddog-gov.com/api/v2/static-analysis/secrets/ruleshttps://api.us2.ddog-gov.com/api/v2/static-analysis/secrets/ruleshttps://api.datadoghq.com/api/v2/static-analysis/secrets/ruleshttps://api.us3.datadoghq.com/api/v2/static-analysis/secrets/ruleshttps://api.us5.datadoghq.com/api/v2/static-analysis/secrets/rules

Overview

Returns a list of Secrets rules with ID, Pattern, Description, Priority, and SDS ID.

OAuth apps require the code_analysis_read authorization scope to access this endpoint.

Response

OK

A collection of secret detection rules returned by the list endpoint.

Expand All

Field

Type

Description

data [required]

[object]

The list of secret detection rules.

attributes

object

The attributes of a secret detection rule, including its pattern, priority, and validation configuration.

default_included_keywords

[string]

A list of keywords that are included by default when scanning for secrets matching this rule.

description

string

A detailed explanation of what type of secret this rule detects.

license

string

The license under which this secret rule is distributed.

match_validation

object

Configuration for validating whether a detected secret is active by making an HTTP request and inspecting the response.

endpoint

string

The URL endpoint to call when validating a detected secret.

hosts

[string]

The list of hostnames to include when performing secret match validation.

http_method

string

The HTTP method (e.g., GET, POST) to use when making the validation request.

invalid_http_status_code

[object]

The HTTP status code ranges that indicate the detected secret is invalid or inactive.

end

int64

The inclusive upper bound of the HTTP status code range.

start

int64

The inclusive lower bound of the HTTP status code range.

request_headers

object

A map of HTTP header names to values to include in the validation request.

<any-key>

string

timeout_seconds

int64

The maximum number of seconds to wait for a response during validation before timing out.

type

string

The type of match validation to perform (e.g., http).

valid_http_status_code

[object]

The HTTP status code ranges that indicate the detected secret is valid and active.

end

int64

The inclusive upper bound of the HTTP status code range.

start

int64

The inclusive lower bound of the HTTP status code range.

name

string

The unique name of the secret detection rule.

pattern

string

The regular expression pattern used to identify potential secrets in source code or configuration.

priority

string

The priority level of this rule, used to rank findings when multiple rules match.

sds_id

string

The identifier of the corresponding Sensitive Data Scanner rule, if one exists.

validators

[string]

A list of validator identifiers used to further confirm a detected secret is genuine.

id

string

The unique identifier of the secret rule resource.

type [required]

enum

Secret rule resource type. Allowed enum values: secret_rule

default: secret_rule

{
  "data": [
    {
      "attributes": {
        "default_included_keywords": [],
        "description": "string",
        "license": "string",
        "match_validation": {
          "endpoint": "string",
          "hosts": [],
          "http_method": "string",
          "invalid_http_status_code": [
            {
              "end": "integer",
              "start": "integer"
            }
          ],
          "request_headers": {
            "<any-key>": "string"
          },
          "timeout_seconds": "integer",
          "type": "string",
          "valid_http_status_code": [
            {
              "end": "integer",
              "start": "integer"
            }
          ]
        },
        "name": "string",
        "pattern": "string",
        "priority": "string",
        "sds_id": "string",
        "validators": []
      },
      "id": "string",
      "type": "secret_rule"
    }
  ]
}

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                  # Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/static-analysis/secrets/rules" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Returns a list of Secrets rules returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi

configuration = Configuration()
configuration.unstable_operations["get_secrets_rules"] = True
with ApiClient(configuration) as api_client:
    api_instance = SecurityMonitoringApi(api_client)
    response = api_instance.get_secrets_rules()

    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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Returns a list of Secrets rules returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.get_secrets_rules".to_sym] = true
end
api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new
p api_instance.get_secrets_rules()

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Returns a list of Secrets rules 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() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.GetSecretsRules", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewSecurityMonitoringApi(apiClient)
	resp, r, err := api.GetSecretsRules(ctx)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetSecretsRules`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetSecretsRules`:\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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Returns a list of Secrets rules returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SecurityMonitoringApi;
import com.datadog.api.client.v2.model.SecretRuleArray;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.getSecretsRules", true);
    SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient);

    try {
      SecretRuleArray result = apiInstance.getSecretsRules();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SecurityMonitoringApi#getSecretsRules");
      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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Returns a list of Secrets rules returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;

#[tokio::main]
async fn main() {
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.GetSecretsRules", true);
    let api = SecurityMonitoringAPI::with_config(configuration);
    let resp = api.get_secrets_rules().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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Returns a list of Secrets rules returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.getSecretsRules"] = true;
const apiInstance = new v2.SecurityMonitoringApi(configuration);

apiInstance
  .getSecretsRules()
  .then((data: v2.SecretRuleArray) => {
    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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"