Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Vulnerabilities endpoints documentation #2950

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-25 17:19:35.598368",
"spec_repo_commit": "7b09d7dd"
"regenerated": "2025-02-26 15:55:39.389396",
"spec_repo_commit": "860a7838"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-25 17:19:35.613826",
"spec_repo_commit": "7b09d7dd"
"regenerated": "2025-02-26 15:55:39.405135",
"spec_repo_commit": "860a7838"
}
}
}
15 changes: 15 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32353,6 +32353,9 @@ components:
apm_service_catalog_read: View service catalog and service definitions.
apm_service_catalog_write: Add, modify, and delete service catalog definitions
when those definitions are maintained by Datadog.
appsec_vm_read: View infrastructure, application code and library vulnerabilities.
This does not restrict access to the vulnerability data source through
the API or inventory SQL.
cases_read: View Cases.
cases_write: Create and update cases.
ci_visibility_pipelines_write: Create CI Visibility pipeline spans using
Expand Down Expand Up @@ -45204,9 +45207,14 @@ paths:
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- appsec_vm_read
summary: List vulnerable assets
tags:
- Security Monitoring
x-unstable: '**Note**: This endpoint is a private preview.

If you are interested in accessing this API, please [fill out this form](https://forms.gle/kMYC1sDr6WDUBDsx9).'
/api/v2/security/cloud_workload/policy/download:
get:
description: 'The download endpoint generates a Cloud Workload Security policy
Expand Down Expand Up @@ -45296,6 +45304,8 @@ paths:
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- appsec_vm_read
summary: Get SBOM
tags:
- Security Monitoring
Expand Down Expand Up @@ -45857,9 +45867,14 @@ paths:
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- appsec_vm_read
summary: List vulnerabilities
tags:
- Security Monitoring
x-unstable: '**Note**: This endpoint is a private preview.

If you are interested in accessing this API, please [fill out this form](https://forms.gle/kMYC1sDr6WDUBDsx9).'
/api/v2/security/vulnerabilities/notification_rules:
get:
description: Returns the list of notification rules for security vulnerabilities.
Expand Down
2 changes: 2 additions & 0 deletions api/datadog/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ func NewConfiguration() *Configuration {
"v2.GetSBOM": false,
"v2.ListFindings": false,
"v2.ListHistoricalJobs": false,
"v2.ListVulnerabilities": false,
"v2.ListVulnerableAssets": false,
"v2.MuteFindings": false,
"v2.RunHistoricalJob": false,
"v2.CreateScorecardOutcomesBatch": false,
Expand Down
18 changes: 18 additions & 0 deletions api/datadogV2/api_security_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -3571,6 +3571,15 @@ func (a *SecurityMonitoringApi) ListVulnerabilities(ctx _context.Context, o ...L
optionalParams = o[0]
}

operationId := "v2.ListVulnerabilities"
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ListVulnerabilities")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
Expand Down Expand Up @@ -3912,6 +3921,15 @@ func (a *SecurityMonitoringApi) ListVulnerableAssets(ctx _context.Context, o ...
optionalParams = o[0]
}

operationId := "v2.ListVulnerableAssets"
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ListVulnerableAssets")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
Expand Down
1 change: 1 addition & 0 deletions examples/v2/security-monitoring/ListVulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.ListVulnerabilities", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewSecurityMonitoringApi(apiClient)
resp, r, err := api.ListVulnerabilities(ctx, *datadogV2.NewListVulnerabilitiesOptionalParameters().WithFilterCvssBaseSeverity(datadogV2.VULNERABILITYSEVERITY_HIGH).WithFilterAssetType(datadogV2.ASSETTYPE_SERVICE).WithFilterTool(datadogV2.VULNERABILITYTOOL_INFRA))
Expand Down
1 change: 1 addition & 0 deletions examples/v2/security-monitoring/ListVulnerableAssets.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.ListVulnerableAssets", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewSecurityMonitoringApi(apiClient)
resp, r, err := api.ListVulnerableAssets(ctx, *datadogV2.NewListVulnerableAssetsOptionalParameters().WithFilterType(datadogV2.ASSETTYPE_HOST).WithFilterRepositoryUrl("github.com/datadog/dd-go").WithFilterRisksInProduction(true))
Expand Down
20 changes: 13 additions & 7 deletions tests/scenarios/features/v2/security_monitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Feature: Security Monitoring
When the request is sent
Then the response status is 404 Not found: asset not found

@team:DataDog/asm-vm
@skip @team:DataDog/asm-vm
Scenario: Get SBOM returns "OK" response
Given operation "GetSBOM" enabled
And new "GetSBOM" request
Expand Down Expand Up @@ -830,21 +830,24 @@ Feature: Security Monitoring

@generated @skip @team:DataDog/asm-vm
Scenario: List vulnerabilities returns "Bad request: The server cannot process the request due to invalid syntax in the request." response
Given new "ListVulnerabilities" request
Given operation "ListVulnerabilities" enabled
And new "ListVulnerabilities" request
When the request is sent
Then the response status is 400 Bad request: The server cannot process the request due to invalid syntax in the request.

@team:DataDog/asm-vm
Scenario: List vulnerabilities returns "Not found: There is no request associated with the provided token." response
Given new "ListVulnerabilities" request
Given operation "ListVulnerabilities" enabled
And new "ListVulnerabilities" request
And request contains "page[token]" parameter with value "unknown"
And request contains "page[number]" parameter with value 1
When the request is sent
Then the response status is 404 Not found: There is no request associated with the provided token.

@team:DataDog/asm-vm
Scenario: List vulnerabilities returns "OK" response
Given new "ListVulnerabilities" request
Given operation "ListVulnerabilities" enabled
And new "ListVulnerabilities" request
And request contains "filter[cvss.base.severity]" parameter with value "High"
And request contains "filter[asset.type]" parameter with value "Service"
And request contains "filter[tool]" parameter with value "Infra"
Expand All @@ -853,21 +856,24 @@ Feature: Security Monitoring

@generated @skip @team:DataDog/asm-vm
Scenario: List vulnerable assets returns "Bad request: The server cannot process the request due to invalid syntax in the request." response
Given new "ListVulnerableAssets" request
Given operation "ListVulnerableAssets" enabled
And new "ListVulnerableAssets" request
When the request is sent
Then the response status is 400 Bad request: The server cannot process the request due to invalid syntax in the request.

@team:DataDog/asm-vm
Scenario: List vulnerable assets returns "Not found: There is no request associated with the provided token." response
Given new "ListVulnerableAssets" request
Given operation "ListVulnerableAssets" enabled
And new "ListVulnerableAssets" request
And request contains "page[token]" parameter with value "unknown"
And request contains "page[number]" parameter with value 1
When the request is sent
Then the response status is 404 Not found: There is no request associated with the provided token.

@team:DataDog/asm-vm
Scenario: List vulnerable assets returns "OK" response
Given new "ListVulnerableAssets" request
Given operation "ListVulnerableAssets" enabled
And new "ListVulnerableAssets" request
And request contains "filter[type]" parameter with value "Host"
And request contains "filter[repository_url]" parameter with value "github.com/datadog/dd-go"
And request contains "filter[risks.in_production]" parameter with value true
Expand Down
Loading