diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4d0c4849320a..5235bcb17ce3 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -64757,6 +64757,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/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 fb630772c1cb..85b612d9d9c1 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -3012,6 +3012,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/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index 38db9644b98b..9d2881592011 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -3891,6 +3891,20 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "SecurityMonitoringSuppressionResponse", }, + "SecurityMonitoringApi.V2.GetSuppressionsAffectingFutureRule": { + body: { + type: "SecurityMonitoringRuleCreatePayload", + format: "", + }, + operationResponseType: "SecurityMonitoringSuppressionsResponse", + }, + "SecurityMonitoringApi.V2.GetSuppressionsAffectingRule": { + ruleId: { + type: "string", + format: "", + }, + operationResponseType: "SecurityMonitoringSuppressionsResponse", + }, "SecurityMonitoringApi.V2.GetSecurityMonitoringSuppression": { suppressionId: { type: "string", diff --git a/services/security_monitoring/src/v2/SecurityMonitoringApi.ts b/services/security_monitoring/src/v2/SecurityMonitoringApi.ts index eda356fe47ce..1a6efd67a0c2 100644 --- a/services/security_monitoring/src/v2/SecurityMonitoringApi.ts +++ b/services/security_monitoring/src/v2/SecurityMonitoringApi.ts @@ -1810,6 +1810,104 @@ 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 { server, overrides } = _config.getServerAndOverrides( + "SecurityMonitoringApi.v2.getSuppressionsAffectingFutureRule", + SecurityMonitoringApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.POST, + overrides, + ); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Body Params + const contentType = getPreferredMediaType(["application/json"]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = stringify( + serialize(body, TypingInfo, "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 { server, overrides } = _config.getServerAndOverrides( + "SecurityMonitoringApi.v2.getSuppressionsAffectingRule", + SecurityMonitoringApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.GET, + overrides, + ); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + "AuthZ", + ]); + + return requestContext; + } + public async getVulnerabilityNotificationRule( id: string, _options?: Configuration, @@ -5681,6 +5779,126 @@ 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 = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: SecurityMonitoringSuppressionsResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "SecurityMonitoringSuppressionsResponse", + ) as SecurityMonitoringSuppressionsResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 429 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "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 = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "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 = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: SecurityMonitoringSuppressionsResponse = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "SecurityMonitoringSuppressionsResponse", + ) as SecurityMonitoringSuppressionsResponse; + return body; + } + if ( + response.httpStatusCode === 403 || + response.httpStatusCode === 404 || + response.httpStatusCode === 429 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "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 = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "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 @@ -7530,6 +7748,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. @@ -8922,6 +9155,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/services/security_monitoring/src/v2/index.ts b/services/security_monitoring/src/v2/index.ts index 43bd957f1c49..6a41e9ded456 100644 --- a/services/security_monitoring/src/v2/index.ts +++ b/services/security_monitoring/src/v2/index.ts @@ -30,6 +30,8 @@ export { SecurityMonitoringApiGetSecurityMonitoringSignalRequest, SecurityMonitoringApiGetSecurityMonitoringSuppressionRequest, SecurityMonitoringApiGetSignalNotificationRuleRequest, + SecurityMonitoringApiGetSuppressionsAffectingFutureRuleRequest, + SecurityMonitoringApiGetSuppressionsAffectingRuleRequest, SecurityMonitoringApiGetVulnerabilityNotificationRuleRequest, SecurityMonitoringApiListAssetsSBOMsRequest, SecurityMonitoringApiListFindingsRequest,