Skip to content

[K9VULN-5176] Added new optional field definition to include more detail in findings for '/api/v2/posture_management/findings' #2863

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

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-05-14 15:44:18.459381",
"spec_repo_commit": "64f5e7ee"
"regenerated": "2025-05-16 10:37:08.566052",
"spec_repo_commit": "302f87a7"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-05-14 15:44:18.474808",
"spec_repo_commit": "64f5e7ee"
"regenerated": "2025-05-16 10:37:08.582842",
"spec_repo_commit": "302f87a7"
}
}
}
50 changes: 43 additions & 7 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14944,6 +14944,10 @@ components:
FindingAttributes:
description: The JSON:API attributes of the finding.
properties:
datadog_link:
$ref: '#/components/schemas/FindingDatadogLink'
description:
$ref: '#/components/schemas/FindingDescription'
evaluation:
$ref: '#/components/schemas/FindingEvaluation'
evaluation_changed_at:
Expand All @@ -14965,6 +14969,25 @@ components:
vulnerability_type:
$ref: '#/components/schemas/FindingVulnerabilityType'
type: object
FindingDatadogLink:
description: The Datadog relative link for this finding.
example: /security/compliance?panels=cpfinding%7Cevent%7CruleId%3Adef-000-u5t%7CresourceId%3Ae8c9ab7c52ebd7bf2fdb4db641082d7d%7CtabId%3Aoverview
type: string
FindingDescription:
description: The description and remediation steps for this finding.
example: '## Remediation


### From the console


1. Go to Storage Account

2. For each Storage Account, navigate to Data Protection

3. Select Set soft delete enabled and enter the number of days to retain soft
deleted data.'
type: string
FindingEvaluation:
description: The evaluation of the finding.
enum:
Expand Down Expand Up @@ -52046,13 +52069,18 @@ paths:
the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.\n\nQuery
parameters must be only among the documented ones and with values of correct
types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`)
are not allowed.\n\n### Response\n\nThe response includes an array of finding
objects, pagination metadata, and a count of items that match the query.\n\nEach
finding object contains the following:\n\n- The finding ID that can be used
in a `GetFinding` request to retrieve the full finding details.\n- Core attributes,
including status, evaluation, high-level resource details, muted state, and
rule details.\n- `evaluation_changed_at` and `resource_discovery_date` time
stamps.\n- An array of associated tags.\n"
are not allowed.\n\n### Additional Extension\n\nAdditional extension fields
are available for some findings.\n\nThe data is available by including the
query parameter `?detailed_findings=true` in the request.\n\nThe following
fields are available for findings:\n- `description`: The description and remediation
steps for this finding.\n- `datadog_link`: The Datadog relative link for this
finding.\n\n### Response\n\nThe response includes an array of finding objects,
pagination metadata, and a count of items that match the query.\n\nEach finding
object contains the following:\n\n- The finding ID that can be used in a `GetFinding`
request to retrieve the full finding details.\n- Core attributes, including
status, evaluation, high-level resource details, muted state, and rule details.\n-
`evaluation_changed_at` and `resource_discovery_date` time stamps.\n- An array
of associated tags.\n"
operationId: ListFindings
parameters:
- description: Limit the number of findings returned. Must be <= 1000.
Expand Down Expand Up @@ -52155,6 +52183,14 @@ paths:
items:
$ref: '#/components/schemas/FindingVulnerabilityType'
type: array
- description: Return additional fields for some findings.
example:
- true
in: query
name: detailed_findings
required: false
schema:
type: boolean
responses:
'200':
content:
Expand Down
27 changes: 27 additions & 0 deletions examples/v2/security-monitoring/ListFindings_2932019633.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// List findings returns "OK" response with details

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.api.SecurityMonitoringApi.ListFindingsOptionalParameters;
import com.datadog.api.client.v2.model.ListFindingsResponse;

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

try {
ListFindingsResponse result =
apiInstance.listFindings(new ListFindingsOptionalParameters().detailedFindings(true));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling SecurityMonitoringApi#listFindings");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5132,6 +5132,7 @@ public static class ListFindingsOptionalParameters {
private FindingEvaluation filterEvaluation;
private FindingStatus filterStatus;
private List<FindingVulnerabilityType> filterVulnerabilityType;
private Boolean detailedFindings;

/**
* Set pageLimit.
Expand Down Expand Up @@ -5285,6 +5286,17 @@ public ListFindingsOptionalParameters filterVulnerabilityType(
this.filterVulnerabilityType = filterVulnerabilityType;
return this;
}

/**
* Set detailedFindings.
*
* @param detailedFindings Return additional fields for some findings. (optional)
* @return ListFindingsOptionalParameters
*/
public ListFindingsOptionalParameters detailedFindings(Boolean detailedFindings) {
this.detailedFindings = detailedFindings;
return this;
}
}

/**
Expand Down Expand Up @@ -5435,6 +5447,17 @@ public PaginationIterable<Finding> listFindingsWithPagination(
* Duplicated query parameters (e.g. <code>filter[status]=low&amp;filter[status]=info</code>) are
* not allowed.
*
* <h3>Additional Extension</h3>
*
* <p>Additional extension fields are available for some findings.
*
* <p>The data is available by including the query parameter <code>?detailed_findings=true</code>
* in the request.
*
* <p>The following fields are available for findings: - <code>description</code>: The description
* and remediation steps for this finding. - <code>datadog_link</code>: The Datadog relative link
* for this finding.
*
* <h3>Response</h3>
*
* <p>The response includes an array of finding objects, pagination metadata, and a count of items
Expand Down Expand Up @@ -5488,6 +5511,7 @@ public ApiResponse<ListFindingsResponse> listFindingsWithHttpInfo(
FindingEvaluation filterEvaluation = parameters.filterEvaluation;
FindingStatus filterStatus = parameters.filterStatus;
List<FindingVulnerabilityType> filterVulnerabilityType = parameters.filterVulnerabilityType;
Boolean detailedFindings = parameters.detailedFindings;
// create path and map variables
String localVarPath = "/api/v2/posture_management/findings";

Expand All @@ -5513,6 +5537,8 @@ public ApiResponse<ListFindingsResponse> listFindingsWithHttpInfo(
localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[status]", filterStatus));
localVarQueryParams.addAll(
apiClient.parameterToPairs("multi", "filter[vulnerability_type]", filterVulnerabilityType));
localVarQueryParams.addAll(
apiClient.parameterToPairs("", "detailed_findings", detailedFindings));

Invocation.Builder builder =
apiClient.createBuilder(
Expand Down Expand Up @@ -5568,6 +5594,7 @@ public CompletableFuture<ApiResponse<ListFindingsResponse>> listFindingsWithHttp
FindingEvaluation filterEvaluation = parameters.filterEvaluation;
FindingStatus filterStatus = parameters.filterStatus;
List<FindingVulnerabilityType> filterVulnerabilityType = parameters.filterVulnerabilityType;
Boolean detailedFindings = parameters.detailedFindings;
// create path and map variables
String localVarPath = "/api/v2/posture_management/findings";

Expand All @@ -5593,6 +5620,8 @@ public CompletableFuture<ApiResponse<ListFindingsResponse>> listFindingsWithHttp
localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[status]", filterStatus));
localVarQueryParams.addAll(
apiClient.parameterToPairs("multi", "filter[vulnerability_type]", filterVulnerabilityType));
localVarQueryParams.addAll(
apiClient.parameterToPairs("", "detailed_findings", detailedFindings));

Invocation.Builder builder;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/** The JSON:API attributes of the finding. */
@JsonPropertyOrder({
FindingAttributes.JSON_PROPERTY_DATADOG_LINK,
FindingAttributes.JSON_PROPERTY_DESCRIPTION,
FindingAttributes.JSON_PROPERTY_EVALUATION,
FindingAttributes.JSON_PROPERTY_EVALUATION_CHANGED_AT,
FindingAttributes.JSON_PROPERTY_MUTE,
Expand All @@ -35,6 +37,12 @@
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
public class FindingAttributes {
@JsonIgnore public boolean unparsed = false;
public static final String JSON_PROPERTY_DATADOG_LINK = "datadog_link";
private String datadogLink;

public static final String JSON_PROPERTY_DESCRIPTION = "description";
private String description;

public static final String JSON_PROPERTY_EVALUATION = "evaluation";
private FindingEvaluation evaluation;

Expand Down Expand Up @@ -65,6 +73,48 @@ public class FindingAttributes {
public static final String JSON_PROPERTY_VULNERABILITY_TYPE = "vulnerability_type";
private FindingVulnerabilityType vulnerabilityType;

public FindingAttributes datadogLink(String datadogLink) {
this.datadogLink = datadogLink;
return this;
}

/**
* The Datadog relative link for this finding.
*
* @return datadogLink
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DATADOG_LINK)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getDatadogLink() {
return datadogLink;
}

public void setDatadogLink(String datadogLink) {
this.datadogLink = datadogLink;
}

public FindingAttributes description(String description) {
this.description = description;
return this;
}

/**
* The description and remediation steps for this finding.
*
* @return description
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DESCRIPTION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public FindingAttributes evaluation(FindingEvaluation evaluation) {
this.evaluation = evaluation;
this.unparsed |= !evaluation.isValid();
Expand Down Expand Up @@ -353,7 +403,9 @@ public boolean equals(Object o) {
return false;
}
FindingAttributes findingAttributes = (FindingAttributes) o;
return Objects.equals(this.evaluation, findingAttributes.evaluation)
return Objects.equals(this.datadogLink, findingAttributes.datadogLink)
&& Objects.equals(this.description, findingAttributes.description)
&& Objects.equals(this.evaluation, findingAttributes.evaluation)
&& Objects.equals(this.evaluationChangedAt, findingAttributes.evaluationChangedAt)
&& Objects.equals(this.mute, findingAttributes.mute)
&& Objects.equals(this.resource, findingAttributes.resource)
Expand All @@ -369,6 +421,8 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
return Objects.hash(
datadogLink,
description,
evaluation,
evaluationChangedAt,
mute,
Expand All @@ -386,6 +440,8 @@ public int hashCode() {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class FindingAttributes {\n");
sb.append(" datadogLink: ").append(toIndentedString(datadogLink)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" evaluation: ").append(toIndentedString(evaluation)).append("\n");
sb.append(" evaluationChangedAt: ")
.append(toIndentedString(evaluationChangedAt))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,14 @@ Feature: Security Monitoring
Then the response status is 200 OK
And the response "data[0].type" is equal to "finding"

@replay-only @team:DataDog/cloud-security-posture-management
Scenario: List findings returns "OK" response with details
Given operation "ListFindings" enabled
And new "ListFindings" request
And request contains "detailed_findings" parameter with value true
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/cloud-security-posture-management @with-pagination
Scenario: List findings returns "OK" response with pagination
Given operation "ListFindings" enabled
Expand Down
Loading