From de5a48862a70d3ec46791e8386d7a7d92b2b29f9 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Sat, 30 Aug 2025 15:37:16 +0000 Subject: [PATCH] Regenerate client from commit fc62e2e of spec repo --- .generator/schemas/v2/openapi.yaml | 59 ++++ .../frozen.json | 1 + .../recording.har | 57 ++++ .../frozen.json | 1 + .../recording.har | 147 ++++++++++ .../frozen.json | 1 + .../recording.har | 67 +++++ .../frozen.json | 1 + .../recording.har | 67 +++++ .../GetSuppressionsAffectingFutureRule.ts | 51 ++++ .../GetSuppressionsAffectingRule.ts | 24 ++ features/support/scenarios_model_mapping.ts | 14 + features/v2/security_monitoring.feature | 29 ++ ...oring_future_rule_suppression_payload.json | 30 ++ features/v2/undo.json | 12 + .../apis/SecurityMonitoringApi.ts | 270 ++++++++++++++++++ packages/datadog-api-client-v2/index.ts | 2 + 17 files changed, 833 insertions(+) create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/frozen.json create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/recording.har create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/frozen.json create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/recording.har create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/frozen.json create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/recording.har create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/frozen.json create mode 100644 cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/recording.har create mode 100644 examples/v2/security-monitoring/GetSuppressionsAffectingFutureRule.ts create mode 100644 examples/v2/security-monitoring/GetSuppressionsAffectingRule.ts create mode 100644 features/v2/security_monitoring_future_rule_suppression_payload.json diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a0f0a2bd0980..48a478f38fbc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -63779,6 +63779,65 @@ paths: tags: - Security Monitoring x-codegen-request-body-name: body + /api/v2/security_monitoring/configuration/suppressions/rules: + post: + description: Get the list of suppressions that would affect a rule. + operationId: GetSuppressionsAffectingFutureRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SecurityMonitoringRuleCreatePayload' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SecurityMonitoringSuppressionsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_suppressions_read + summary: Get suppressions affecting future rule + tags: + - Security Monitoring + /api/v2/security_monitoring/configuration/suppressions/rules/{rule_id}: + get: + description: Get the list of suppressions that affect a specific existing rule + by its ID. + operationId: GetSuppressionsAffectingRule + parameters: + - $ref: '#/components/parameters/SecurityMonitoringRuleID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SecurityMonitoringSuppressionsResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_suppressions_read + summary: Get suppressions affecting a specific rule + tags: + - Security Monitoring /api/v2/security_monitoring/configuration/suppressions/{suppression_id}: delete: description: Delete a specific suppression rule. diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/frozen.json b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/frozen.json new file mode 100644 index 000000000000..b77b238b9c65 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/frozen.json @@ -0,0 +1 @@ +"2025-08-30T15:29:04.687Z" diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/recording.har b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/recording.har new file mode 100644 index 000000000000..04af2c8aecc7 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-Not-Found-response_1206641090/recording.har @@ -0,0 +1,57 @@ +{ + "log": { + "_recordingName": "Security Monitoring/Get suppressions affecting a specific rule returns \"Not Found\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "9d5ff251844ce2b3c1906442c1b68494", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 577, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/configuration/suppressions/rules/aaa-bbb-ccc-ddd" + }, + "response": { + "bodySize": 74, + "content": { + "mimeType": "application/json", + "size": 74, + "text": "{\"errors\":[\"not_found(Threat detection rule not found: aaa-bbb-ccc-ddd)\"]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 653, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 404, + "statusText": "Not Found" + }, + "startedDateTime": "2025-08-30T15:29:04.690Z", + "time": 400 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/frozen.json b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/frozen.json new file mode 100644 index 000000000000..a03e6e6ad306 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/frozen.json @@ -0,0 +1 @@ +"2025-08-30T11:40:50.061Z" diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/recording.har b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/recording.har new file mode 100644 index 000000000000..644d233d364e --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-a-specific-rule-returns-OK-response_696202133/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "Security Monitoring/Get suppressions affecting a specific rule returns \"OK\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "e94c52d6c7333f0907bb9c1b2513cce2", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 438, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 588, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"cases\":[{\"condition\":\"a > 0\",\"name\":\"\",\"notifications\":[],\"status\":\"info\"}],\"filters\":[],\"isEnabled\":true,\"message\":\"Test rule\",\"name\":\"Test-Get_suppressions_affecting_a_specific_rule_returns_OK_response-1756554050\",\"options\":{\"evaluationWindow\":900,\"keepAlive\":3600,\"maxSignalDuration\":86400},\"queries\":[{\"aggregation\":\"count\",\"distinctFields\":[],\"groupByFields\":[],\"metrics\":[],\"query\":\"@test:true\"}],\"tags\":[],\"type\":\"log_detection\"}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/rules" + }, + "response": { + "bodySize": 873, + "content": { + "mimeType": "application/json", + "size": 873, + "text": "{\"name\":\"Test-Get_suppressions_affecting_a_specific_rule_returns_OK_response-1756554050\",\"createdAt\":1756554050604,\"isDefault\":false,\"isPartner\":false,\"isEnabled\":true,\"isBeta\":false,\"isDeleted\":false,\"isDeprecated\":false,\"queries\":[{\"query\":\"@test:true\",\"groupByFields\":[],\"hasOptionalGroupByFields\":false,\"distinctFields\":[],\"aggregation\":\"count\",\"name\":\"\",\"dataSource\":\"logs\"}],\"options\":{\"evaluationWindow\":900,\"detectionMethod\":\"threshold\",\"maxSignalDuration\":86400,\"keepAlive\":3600},\"cases\":[{\"name\":\"\",\"status\":\"info\",\"notifications\":[],\"condition\":\"a \\u003e 0\"}],\"message\":\"Test rule\",\"tags\":[],\"hasExtendedTitle\":false,\"type\":\"log_detection\",\"filters\":[],\"version\":1,\"id\":\"wrh-hm6-4zf\",\"blocking\":false,\"metadata\":{\"entities\":null,\"sources\":null},\"creationAuthorId\":1445416,\"creator\":{\"handle\":\"frog@datadoghq.com\",\"name\":\"frog\"},\"updater\":{\"handle\":\"\",\"name\":\"\"}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 655, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-08-30T11:40:50.067Z", + "time": 596 + }, + { + "_id": "fc789d52da95d58b5dee10bf3c714339", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 573, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/configuration/suppressions/rules/wrh-hm6-4zf" + }, + "response": { + "bodySize": 11, + "content": { + "mimeType": "application/vnd.api+json", + "size": 11, + "text": "{\"data\":[]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 661, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-08-30T11:40:50.672Z", + "time": 528 + }, + { + "_id": "c506ab20ac5d557566faea6f521afeba", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + } + ], + "headersSize": 536, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/rules/wrh-hm6-4zf" + }, + "response": { + "bodySize": 0, + "content": { + "mimeType": "text/plain", + "size": 0 + }, + "cookies": [], + "headers": [], + "headersSize": 601, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 204, + "statusText": "No Content" + }, + "startedDateTime": "2025-08-30T11:40:51.206Z", + "time": 221 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/frozen.json b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/frozen.json new file mode 100644 index 000000000000..68ad327e69c1 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/frozen.json @@ -0,0 +1 @@ +"2025-08-30T15:29:48.867Z" diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/recording.har b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/recording.har new file mode 100644 index 000000000000..800a97cc7a00 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-Bad-Request-response_128624447/recording.har @@ -0,0 +1,67 @@ +{ + "log": { + "_recordingName": "Security Monitoring/Get suppressions affecting future rule returns \"Bad Request\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "fd9fc85327a5b7809be44020c43d12db", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 31, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 620, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"invalid_key\":\"invalid_value\"}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/configuration/suppressions/rules" + }, + "response": { + "bodySize": 59, + "content": { + "mimeType": "application/json", + "size": 59, + "text": "{\"errors\":[\"invalid_argument(Invalid rule configuration)\"]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 653, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 400, + "statusText": "Bad Request" + }, + "startedDateTime": "2025-08-30T15:29:48.872Z", + "time": 401 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/frozen.json b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/frozen.json new file mode 100644 index 000000000000..1ca7c08fe180 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/frozen.json @@ -0,0 +1 @@ +"2025-08-30T15:30:01.229Z" diff --git a/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/recording.har b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/recording.har new file mode 100644 index 000000000000..c890fe0dc674 --- /dev/null +++ b/cassettes/v2/Security-Monitoring_1187227211/Get-suppressions-affecting-future-rule-returns-OK-response_3478245675/recording.har @@ -0,0 +1,67 @@ +{ + "log": { + "_recordingName": "Security Monitoring/Get suppressions affecting future rule returns \"OK\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "443d50549a0b8ef9ee88566128ab95c2", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 434, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 619, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"cases\":[{\"condition\":\"a > 0\",\"name\":\"\",\"notifications\":[],\"status\":\"info\"}],\"filters\":[],\"isEnabled\":true,\"message\":\"Test rule\",\"name\":\"Test-Get_suppressions_affecting_future_rule_returns_OK_response-1756567801\",\"options\":{\"evaluationWindow\":900,\"keepAlive\":3600,\"maxSignalDuration\":86400},\"queries\":[{\"aggregation\":\"count\",\"distinctFields\":[],\"groupByFields\":[],\"metrics\":[],\"query\":\"@test:true\"}],\"tags\":[],\"type\":\"log_detection\"}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/security_monitoring/configuration/suppressions/rules" + }, + "response": { + "bodySize": 11, + "content": { + "mimeType": "application/vnd.api+json", + "size": 11, + "text": "{\"data\":[]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 661, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-08-30T15:30:01.235Z", + "time": 420 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/examples/v2/security-monitoring/GetSuppressionsAffectingFutureRule.ts b/examples/v2/security-monitoring/GetSuppressionsAffectingFutureRule.ts new file mode 100644 index 000000000000..69245a4cf768 --- /dev/null +++ b/examples/v2/security-monitoring/GetSuppressionsAffectingFutureRule.ts @@ -0,0 +1,51 @@ +/** + * Get suppressions affecting future rule returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v2.SecurityMonitoringApi(configuration); + +const params: v2.SecurityMonitoringApiGetSuppressionsAffectingFutureRuleRequest = + { + body: { + name: "Example-Security-Monitoring", + queries: [ + { + query: "@test:true", + aggregation: "count", + groupByFields: [], + distinctFields: [], + metrics: [], + }, + ], + filters: [], + cases: [ + { + name: "", + status: "info", + condition: "a > 0", + notifications: [], + }, + ], + options: { + evaluationWindow: 900, + keepAlive: 3600, + maxSignalDuration: 86400, + }, + message: "Test rule", + tags: [], + isEnabled: true, + type: "log_detection", + }, + }; + +apiInstance + .getSuppressionsAffectingFutureRule(params) + .then((data: v2.SecurityMonitoringSuppressionsResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/security-monitoring/GetSuppressionsAffectingRule.ts b/examples/v2/security-monitoring/GetSuppressionsAffectingRule.ts new file mode 100644 index 000000000000..0da197ce04c7 --- /dev/null +++ b/examples/v2/security-monitoring/GetSuppressionsAffectingRule.ts @@ -0,0 +1,24 @@ +/** + * Get suppressions affecting a specific rule returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v2.SecurityMonitoringApi(configuration); + +// there is a valid "security_rule" in the system +const SECURITY_RULE_ID = process.env.SECURITY_RULE_ID as string; + +const params: v2.SecurityMonitoringApiGetSuppressionsAffectingRuleRequest = { + ruleId: SECURITY_RULE_ID, +}; + +apiInstance + .getSuppressionsAffectingRule(params) + .then((data: v2.SecurityMonitoringSuppressionsResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/features/support/scenarios_model_mapping.ts b/features/support/scenarios_model_mapping.ts index 83bb2b3f84ad..e9e8f86af5cf 100644 --- a/features/support/scenarios_model_mapping.ts +++ b/features/support/scenarios_model_mapping.ts @@ -3881,6 +3881,20 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "SecurityMonitoringSuppressionResponse", }, + "v2.GetSuppressionsAffectingFutureRule": { + "body": { + "type": "SecurityMonitoringRuleCreatePayload", + "format": "", + }, + "operationResponseType": "SecurityMonitoringSuppressionsResponse", + }, + "v2.GetSuppressionsAffectingRule": { + "ruleId": { + "type": "string", + "format": "", + }, + "operationResponseType": "SecurityMonitoringSuppressionsResponse", + }, "v2.GetSecurityMonitoringSuppression": { "suppressionId": { "type": "string", diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index 1ef29aec3e61..bf07efac5ff2 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -822,6 +822,35 @@ Feature: Security Monitoring And the response "data.attributes.count" is equal to 1 And the response "data.attributes.data[1].rule.name" has the same value as "security_rule.name" + @team:DataDog/k9-cloud-security-platform + Scenario: Get suppressions affecting a specific rule returns "Not Found" response + Given new "GetSuppressionsAffectingRule" request + And request contains "rule_id" parameter with value "aaa-bbb-ccc-ddd" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-cloud-security-platform + Scenario: Get suppressions affecting a specific rule returns "OK" response + Given new "GetSuppressionsAffectingRule" request + And there is a valid "security_rule" in the system + And request contains "rule_id" parameter from "security_rule.id" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/k9-cloud-security-platform + Scenario: Get suppressions affecting future rule returns "Bad Request" response + Given new "GetSuppressionsAffectingFutureRule" request + And body with value {"invalid_key":"invalid_value"} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/k9-cloud-security-platform + Scenario: Get suppressions affecting future rule returns "OK" response + Given new "GetSuppressionsAffectingFutureRule" request + And body from file "security_monitoring_future_rule_suppression_payload.json" + When the request is sent + Then the response status is 200 OK + @team:DataDog/cloud-security-posture-management Scenario: Get the list of signal-based notification rules returns "The list of notification rules." response Given there is a valid "valid_signal_notification_rule" in the system diff --git a/features/v2/security_monitoring_future_rule_suppression_payload.json b/features/v2/security_monitoring_future_rule_suppression_payload.json new file mode 100644 index 000000000000..b2c79709b069 --- /dev/null +++ b/features/v2/security_monitoring_future_rule_suppression_payload.json @@ -0,0 +1,30 @@ +{ + "name": "{{ unique }}", + "queries": [ + { + "query": "@test:true", + "aggregation": "count", + "groupByFields": [], + "distinctFields": [], + "metrics": [] + } + ], + "filters": [], + "cases": [ + { + "name": "", + "status": "info", + "condition": "a > 0", + "notifications": [] + } + ], + "options": { + "evaluationWindow": 900, + "keepAlive": 3600, + "maxSignalDuration": 86400 + }, + "message": "Test rule", + "tags": [], + "isEnabled": true, + "type": "log_detection" +} diff --git a/features/v2/undo.json b/features/v2/undo.json index ec94e15e11da..f22f1836a158 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2988,6 +2988,18 @@ "type": "unsafe" } }, + "GetSuppressionsAffectingFutureRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "GetSuppressionsAffectingRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "DeleteSecurityMonitoringSuppression": { "tag": "Security Monitoring", "undo": { diff --git a/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts b/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts index 2929229338f8..3e7e61683fa0 100644 --- a/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts +++ b/packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts @@ -1454,6 +1454,88 @@ export class SecurityMonitoringApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async getSuppressionsAffectingFutureRule( + body: SecurityMonitoringRuleCreatePayload, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "getSuppressionsAffectingFutureRule"); + } + + // Path Params + const localVarPath = + "/api/v2/security_monitoring/configuration/suppressions/rules"; + + // Make Request Context + const requestContext = _config + .getServer("v2.SecurityMonitoringApi.getSuppressionsAffectingFutureRule") + .makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize( + body, + "SecurityMonitoringRuleCreatePayload", + "" + ), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + + public async getSuppressionsAffectingRule( + ruleId: string, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'ruleId' is not null or undefined + if (ruleId === null || ruleId === undefined) { + throw new RequiredError("ruleId", "getSuppressionsAffectingRule"); + } + + // Path Params + const localVarPath = + "/api/v2/security_monitoring/configuration/suppressions/rules/{rule_id}".replace( + "{rule_id}", + encodeURIComponent(String(ruleId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.SecurityMonitoringApi.getSuppressionsAffectingRule") + .makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async getVulnerabilityNotificationRule( id: string, _options?: Configuration @@ -5199,6 +5281,134 @@ export class SecurityMonitoringApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getSuppressionsAffectingFutureRule + * @throws ApiException if the response code was not in [200, 299] + */ + public async getSuppressionsAffectingFutureRule( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: SecurityMonitoringSuppressionsResponse = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "SecurityMonitoringSuppressionsResponse" + ) as SecurityMonitoringSuppressionsResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 429 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: SecurityMonitoringSuppressionsResponse = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "SecurityMonitoringSuppressionsResponse", + "" + ) as SecurityMonitoringSuppressionsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getSuppressionsAffectingRule + * @throws ApiException if the response code was not in [200, 299] + */ + public async getSuppressionsAffectingRule( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: SecurityMonitoringSuppressionsResponse = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "SecurityMonitoringSuppressionsResponse" + ) as SecurityMonitoringSuppressionsResponse; + return body; + } + if ( + response.httpStatusCode === 403 || + response.httpStatusCode === 404 || + response.httpStatusCode === 429 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: SecurityMonitoringSuppressionsResponse = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "SecurityMonitoringSuppressionsResponse", + "" + ) as SecurityMonitoringSuppressionsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -7124,6 +7334,21 @@ export interface SecurityMonitoringApiGetSignalNotificationRuleRequest { id: string; } +export interface SecurityMonitoringApiGetSuppressionsAffectingFutureRuleRequest { + /** + * @type SecurityMonitoringRuleCreatePayload + */ + body: SecurityMonitoringRuleCreatePayload; +} + +export interface SecurityMonitoringApiGetSuppressionsAffectingRuleRequest { + /** + * The ID of the rule. + * @type string + */ + ruleId: string; +} + export interface SecurityMonitoringApiGetVulnerabilityNotificationRuleRequest { /** * ID of the notification rule. @@ -8513,6 +8738,51 @@ export class SecurityMonitoringApi { }); } + /** + * Get the list of suppressions that would affect a rule. + * @param param The request object + */ + public getSuppressionsAffectingFutureRule( + param: SecurityMonitoringApiGetSuppressionsAffectingFutureRuleRequest, + options?: Configuration + ): Promise { + const requestContextPromise = + this.requestFactory.getSuppressionsAffectingFutureRule( + param.body, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.getSuppressionsAffectingFutureRule( + responseContext + ); + }); + }); + } + + /** + * Get the list of suppressions that affect a specific existing rule by its ID. + * @param param The request object + */ + public getSuppressionsAffectingRule( + param: SecurityMonitoringApiGetSuppressionsAffectingRuleRequest, + options?: Configuration + ): Promise { + const requestContextPromise = + this.requestFactory.getSuppressionsAffectingRule(param.ruleId, options); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.getSuppressionsAffectingRule( + responseContext + ); + }); + }); + } + /** * Get the details of a notification rule for security vulnerabilities. * @param param The request object diff --git a/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index f87b74b7fca9..2bb51398dc01 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -602,6 +602,8 @@ export { SecurityMonitoringApiGetSecurityMonitoringSignalRequest, SecurityMonitoringApiGetSecurityMonitoringSuppressionRequest, SecurityMonitoringApiGetSignalNotificationRuleRequest, + SecurityMonitoringApiGetSuppressionsAffectingFutureRuleRequest, + SecurityMonitoringApiGetSuppressionsAffectingRuleRequest, SecurityMonitoringApiGetVulnerabilityNotificationRuleRequest, SecurityMonitoringApiListAssetsSBOMsRequest, SecurityMonitoringApiListFindingsRequest,