Submit libraries for vulnerability scanning
https://api.datadoghq.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.us3.datadoghq.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.us5.datadoghq.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.datadoghq.eu/api/v2/static-analysis-sca/dependencies/scanhttps://api.ap1.datadoghq.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.ap2.datadoghq.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.uk1.datadoghq.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.ddog-gov.com/api/v2/static-analysis-sca/dependencies/scanhttps://api.us2.ddog-gov.com/api/v2/static-analysis-sca/dependencies/scan概要
OAuth apps require the code_analysis_read authorization scope to access this endpoint.
リクエスト
Body Data (required)
data [required]The data object in an MCP SCA scan request, containing the scan attributes and request type.
attributes [required]The attributes of an MCP SCA scan request, describing the libraries to scan and their context.
commit_hash [required]The commit hash of the source code being scanned.
libraries [required]The list of libraries to scan for vulnerabilities.
exclusionsThe list of dependency PURLs to exclude when resolving transitive dependencies for this library.
is_dev [required]Whether this library is a development-only dependency.
is_direct [required]Whether this library is a direct (rather than transitive) dependency.
package_manager [required]The package manager that produced this library entry (for example, npm, pip, nuget).
purl [required]The Package URL (PURL) uniquely identifying the library and its version.
target_frameworksThe list of target framework identifiers associated with the library.
resource_name [required]The name of the resource (typically the repository or project name) being scanned.
idAn optional identifier for this scan request.
type [required]The type identifier for MCP SCA scan requests.
mcpscanrequestmcpscanrequest{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": []
}
],
"resource_name": "my-org/my-repo"
},
"id": "string",
"type": "mcpscanrequest"
}
}応答
Accepted
The top-level response object returned when an MCP SCA dependency scan request has been accepted.
data [required]The data object returned when a scan request has been accepted.
attributes [required]The attributes returned when a scan request has been accepted, containing the job identifier used to poll for results.
job_id [required]The job identifier assigned to the scan, used to retrieve the scan result.
id [required]The job identifier assigned to the scan.
type [required]The type identifier for MCP SCA scan request responses.
mcpscanrequestresponsemcpscanrequestresponse{
"data": {
"attributes": {
"job_id": "0190a3d4-1234-7000-8000-000000000000"
},
"id": "0190a3d4-1234-7000-8000-000000000000",
"type": "mcpscanrequestresponse"
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}コード例
# 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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
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/static-analysis-sca/dependencies/scan" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"commit_hash": "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
"libraries": [
{
"exclusions": [],
"is_dev": false,
"is_direct": true,
"package_manager": "nuget",
"purl": "pkg:nuget/Newtonsoft.Json@13.0.1",
"target_frameworks": [
"net8.0"
]
}
],
"resource_name": "my-org/my-repo"
},
"type": "mcpscanrequest"
}
}
EOF// Submit libraries for vulnerability scanning returns "Accepted" 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.McpScanRequest{
Data: datadogV2.McpScanRequestData{
Attributes: datadogV2.McpScanRequestDataAttributes{
CommitHash: "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
Libraries: []datadogV2.McpScanRequestDataAttributesLibrariesItems{
{
Exclusions: []string{},
IsDev: false,
IsDirect: true,
PackageManager: "nuget",
Purl: "pkg:nuget/Newtonsoft.Json@13.0.1",
TargetFrameworks: []string{},
},
},
ResourceName: "my-org/my-repo",
},
Type: datadogV2.MCPSCANREQUESTDATATYPE_MCPSCANREQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateSCAScan", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewStaticAnalysisApi(apiClient)
resp, r, err := api.CreateSCAScan(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.CreateSCAScan`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `StaticAnalysisApi.CreateSCAScan`:\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"// Submit libraries for vulnerability scanning returns "Accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StaticAnalysisApi;
import com.datadog.api.client.v2.model.McpScanRequest;
import com.datadog.api.client.v2.model.McpScanRequestData;
import com.datadog.api.client.v2.model.McpScanRequestDataAttributes;
import com.datadog.api.client.v2.model.McpScanRequestDataAttributesLibrariesItems;
import com.datadog.api.client.v2.model.McpScanRequestDataType;
import com.datadog.api.client.v2.model.McpScanRequestResponse;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createSCAScan", true);
StaticAnalysisApi apiInstance = new StaticAnalysisApi(defaultClient);
McpScanRequest body =
new McpScanRequest()
.data(
new McpScanRequestData()
.attributes(
new McpScanRequestDataAttributes()
.commitHash("0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc")
.libraries(
Collections.singletonList(
new McpScanRequestDataAttributesLibrariesItems()
.isDev(false)
.isDirect(true)
.packageManager("nuget")
.purl("pkg:nuget/Newtonsoft.Json@13.0.1")))
.resourceName("my-org/my-repo"))
.type(McpScanRequestDataType.MCPSCANREQUEST));
try {
McpScanRequestResponse result = apiInstance.createSCAScan(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling StaticAnalysisApi#createSCAScan");
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""""
Submit libraries for vulnerability scanning returns "Accepted" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi
from datadog_api_client.v2.model.mcp_scan_request import McpScanRequest
from datadog_api_client.v2.model.mcp_scan_request_data import McpScanRequestData
from datadog_api_client.v2.model.mcp_scan_request_data_attributes import McpScanRequestDataAttributes
from datadog_api_client.v2.model.mcp_scan_request_data_attributes_libraries_items import (
McpScanRequestDataAttributesLibrariesItems,
)
from datadog_api_client.v2.model.mcp_scan_request_data_type import McpScanRequestDataType
body = McpScanRequest(
data=McpScanRequestData(
attributes=McpScanRequestDataAttributes(
commit_hash="0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
libraries=[
McpScanRequestDataAttributesLibrariesItems(
exclusions=[],
is_dev=False,
is_direct=True,
package_manager="nuget",
purl="pkg:nuget/Newtonsoft.Json@13.0.1",
target_frameworks=[],
),
],
resource_name="my-org/my-repo",
),
type=McpScanRequestDataType.MCPSCANREQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_sca_scan"] = True
with ApiClient(configuration) as api_client:
api_instance = StaticAnalysisApi(api_client)
response = api_instance.create_sca_scan(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"# Submit libraries for vulnerability scanning returns "Accepted" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_sca_scan".to_sym] = true
end
api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new
body = DatadogAPIClient::V2::McpScanRequest.new({
data: DatadogAPIClient::V2::McpScanRequestData.new({
attributes: DatadogAPIClient::V2::McpScanRequestDataAttributes.new({
commit_hash: "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
libraries: [
DatadogAPIClient::V2::McpScanRequestDataAttributesLibrariesItems.new({
exclusions: [],
is_dev: false,
is_direct: true,
package_manager: "nuget",
purl: "pkg:nuget/Newtonsoft.Json@13.0.1",
target_frameworks: [],
}),
],
resource_name: "my-org/my-repo",
}),
type: DatadogAPIClient::V2::McpScanRequestDataType::MCPSCANREQUEST,
}),
})
p api_instance.create_sca_scan(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"// Submit libraries for vulnerability scanning returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI;
use datadog_api_client::datadogV2::model::McpScanRequest;
use datadog_api_client::datadogV2::model::McpScanRequestData;
use datadog_api_client::datadogV2::model::McpScanRequestDataAttributes;
use datadog_api_client::datadogV2::model::McpScanRequestDataAttributesLibrariesItems;
use datadog_api_client::datadogV2::model::McpScanRequestDataType;
#[tokio::main]
async fn main() {
let body = McpScanRequest::new(McpScanRequestData::new(
McpScanRequestDataAttributes::new(
"0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc".to_string(),
vec![McpScanRequestDataAttributesLibrariesItems::new(
false,
true,
"nuget".to_string(),
"pkg:nuget/Newtonsoft.Json@13.0.1".to_string(),
)
.exclusions(vec![])
.target_frameworks(vec![])],
"my-org/my-repo".to_string(),
),
McpScanRequestDataType::MCPSCANREQUEST,
));
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_sca_scan", true);
let api = StaticAnalysisAPI::with_config(configuration);
let resp = api.create_sca_scan(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="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Submit libraries for vulnerability scanning returns "Accepted" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.createSCAScan"] = true;
const apiInstance = new v2.StaticAnalysisApi(configuration);
const params: v2.StaticAnalysisApiCreateSCAScanRequest = {
body: {
data: {
attributes: {
commitHash: "0e9fc8de83eaabecd722e1cd0ed44fb489fe15fc",
libraries: [
{
exclusions: [],
isDev: false,
isDirect: true,
packageManager: "nuget",
purl: "pkg:nuget/Newtonsoft.Json@13.0.1",
targetFrameworks: [],
},
],
resourceName: "my-org/my-repo",
},
type: "mcpscanrequest",
},
},
};
apiInstance
.createSCAScan(params)
.then((data: v2.McpScanRequestResponse) => {
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"