Skip to content

Commit cd10176

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add SDS rule should_save_match field (#2623)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 859f207 commit cd10176

File tree

7 files changed

+186
-3
lines changed

7 files changed

+186
-3
lines changed

.generated-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"spec_repo_commit": "98e3371",
3-
"generated": "2025-08-27 08:45:02.412"
2+
"spec_repo_commit": "62a19e4",
3+
"generated": "2025-08-27 15:01:20.504"
44
}

.generator/schemas/v2/openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39445,6 +39445,12 @@ components:
3944539445
replacement_string:
3944639446
description: Required if type == 'replacement_string'.
3944739447
type: string
39448+
should_save_match:
39449+
description: "Only valid when type == `replacement_string`. When enabled,
39450+
matches can be unmasked in logs by users with \u2018Data Scanner Unmask\u2019
39451+
permission. As a security best practice, avoid masking for highly-sensitive,
39452+
long-lived data."
39453+
type: boolean
3944839454
type:
3944939455
$ref: '#/components/schemas/SensitiveDataScannerTextReplacementType'
3945039456
type: object
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-08-26T20:31:44.042Z

cassettes/features/v2/sensitive_data_scanner/Create-Scanning-Rule-with-should-save-match-returns-OK-response.yml

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Create Scanning Rule with should_save_match returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V2::SensitiveDataScannerAPI.new
5+
6+
# there is a valid "scanning_group" in the system
7+
GROUP_DATA_ID = ENV["GROUP_DATA_ID"]
8+
9+
body = DatadogAPIClient::V2::SensitiveDataScannerRuleCreateRequest.new({
10+
meta: DatadogAPIClient::V2::SensitiveDataScannerMetaVersionOnly.new({}),
11+
data: DatadogAPIClient::V2::SensitiveDataScannerRuleCreate.new({
12+
type: DatadogAPIClient::V2::SensitiveDataScannerRuleType::SENSITIVE_DATA_SCANNER_RULE,
13+
attributes: DatadogAPIClient::V2::SensitiveDataScannerRuleAttributes.new({
14+
name: "Example-Sensitive-Data-Scanner",
15+
pattern: "pattern",
16+
text_replacement: DatadogAPIClient::V2::SensitiveDataScannerTextReplacement.new({
17+
type: DatadogAPIClient::V2::SensitiveDataScannerTextReplacementType::REPLACEMENT_STRING,
18+
replacement_string: "REDACTED",
19+
should_save_match: true,
20+
}),
21+
tags: [
22+
"sensitive_data:true",
23+
],
24+
is_enabled: true,
25+
priority: 1,
26+
}),
27+
relationships: DatadogAPIClient::V2::SensitiveDataScannerRuleRelationships.new({
28+
group: DatadogAPIClient::V2::SensitiveDataScannerGroupData.new({
29+
data: DatadogAPIClient::V2::SensitiveDataScannerGroup.new({
30+
type: DatadogAPIClient::V2::SensitiveDataScannerGroupType::SENSITIVE_DATA_SCANNER_GROUP,
31+
id: GROUP_DATA_ID,
32+
}),
33+
}),
34+
}),
35+
}),
36+
})
37+
p api_instance.create_scanning_rule(body)

features/v2/sensitive_data_scanner.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ Feature: Sensitive Data Scanner
5050
And the response "data.attributes.included_keyword_configuration.character_count" is equal to 35
5151
And the response "data.attributes.included_keyword_configuration.keywords[0]" is equal to "credit card"
5252

53+
@team:DataDog/sensitive-data-scanner
54+
Scenario: Create Scanning Rule with should_save_match returns "OK" response
55+
Given a valid "configuration" in the system
56+
And there is a valid "scanning_group" in the system
57+
And new "CreateScanningRule" request
58+
And body with value {"meta":{},"data":{"type":"sensitive_data_scanner_rule","attributes":{"name":"{{ unique }}","pattern":"pattern","text_replacement":{"type":"replacement_string","replacement_string":"REDACTED","should_save_match":true},"tags":["sensitive_data:true"],"is_enabled":true,"priority":1},"relationships":{"group":{"data":{"type":"{{ group.data.type }}","id":"{{ group.data.id }}"}}}}}
59+
When the request is sent
60+
Then the response status is 200 OK
61+
And the response "data.type" is equal to "sensitive_data_scanner_rule"
62+
And the response "data.attributes.name" is equal to "{{ unique }}"
63+
5364
@generated @skip @team:DataDog/sensitive-data-scanner
5465
Scenario: Delete Scanning Group returns "Bad Request" response
5566
Given new "DeleteScanningGroup" request

lib/datadog_api_client/v2/models/sensitive_data_scanner_text_replacement.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class SensitiveDataScannerTextReplacement
2828
# Required if type == 'replacement_string'.
2929
attr_accessor :replacement_string
3030

31+
# Only valid when type == `replacement_string`. When enabled, matches can be unmasked in logs by users with ‘Data Scanner Unmask’ permission. As a security best practice, avoid masking for highly-sensitive, long-lived data.
32+
attr_accessor :should_save_match
33+
3134
# Type of the replacement text. None means no replacement.
3235
# hash means the data will be stubbed. replacement_string means that
3336
# one can chose a text to replace the data. partial_replacement_from_beginning
@@ -44,6 +47,7 @@ def self.attribute_map
4447
{
4548
:'number_of_chars' => :'number_of_chars',
4649
:'replacement_string' => :'replacement_string',
50+
:'should_save_match' => :'should_save_match',
4751
:'type' => :'type'
4852
}
4953
end
@@ -54,6 +58,7 @@ def self.openapi_types
5458
{
5559
:'number_of_chars' => :'Integer',
5660
:'replacement_string' => :'String',
61+
:'should_save_match' => :'Boolean',
5762
:'type' => :'SensitiveDataScannerTextReplacementType'
5863
}
5964
end
@@ -84,6 +89,10 @@ def initialize(attributes = {})
8489
self.replacement_string = attributes[:'replacement_string']
8590
end
8691

92+
if attributes.key?(:'should_save_match')
93+
self.should_save_match = attributes[:'should_save_match']
94+
end
95+
8796
if attributes.key?(:'type')
8897
self.type = attributes[:'type']
8998
end
@@ -135,6 +144,7 @@ def ==(o)
135144
self.class == o.class &&
136145
number_of_chars == o.number_of_chars &&
137146
replacement_string == o.replacement_string &&
147+
should_save_match == o.should_save_match &&
138148
type == o.type &&
139149
additional_properties == o.additional_properties
140150
end
@@ -143,7 +153,7 @@ def ==(o)
143153
# @return [Integer] Hash code
144154
# @!visibility private
145155
def hash
146-
[number_of_chars, replacement_string, type, additional_properties].hash
156+
[number_of_chars, replacement_string, should_save_match, type, additional_properties].hash
147157
end
148158
end
149159
end

0 commit comments

Comments
 (0)