Skip to content

Commit 0a5362f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add exists, !exists, equals, and !equals operators to WAF custom rules (#3197)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent c403da3 commit 0a5362f

7 files changed

Lines changed: 78 additions & 6 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,6 +4527,10 @@ components:
45274527
- ip_match
45284528
- "!ip_match"
45294529
- capture_data
4530+
- exists
4531+
- "!exists"
4532+
- equals
4533+
- "!equals"
45304534
example: "match_regex"
45314535
type: string
45324536
x-enum-varnames:
@@ -4541,6 +4545,10 @@ components:
45414545
- IP_MATCH
45424546
- NOT_IP_MATCH
45434547
- CAPTURE_DATA
4548+
- EXISTS
4549+
- NOT_EXISTS
4550+
- EQUALS
4551+
- NOT_EQUALS
45444552
ApplicationSecurityWafCustomRuleConditionOptions:
45454553
description: Options for the operator of this condition.
45464554
properties:
@@ -4581,6 +4589,8 @@ components:
45814589
description: "Regex to use with the condition. Only used with match_regex and !match_regex operator."
45824590
example: "path.*"
45834591
type: string
4592+
type:
4593+
$ref: "#/components/schemas/ApplicationSecurityWafCustomRuleConditionParametersType"
45844594
value:
45854595
description: |-
45864596
Store the captured value in the specified tag name. Only used with the capture_data operator.
@@ -4589,6 +4599,22 @@ components:
45894599
required:
45904600
- inputs
45914601
type: object
4602+
ApplicationSecurityWafCustomRuleConditionParametersType:
4603+
description: The type of the value to compare against. Only used with the equals and !equals operator.
4604+
enum:
4605+
- boolean
4606+
- signed
4607+
- unsigned
4608+
- float
4609+
- string
4610+
example: "string"
4611+
type: string
4612+
x-enum-varnames:
4613+
- BOOLEAN
4614+
- SIGNED
4615+
- UNSIGNED
4616+
- FLOAT
4617+
- STRING
45924618
ApplicationSecurityWafCustomRuleCreateAttributes:
45934619
description: "Create a new WAF custom rule."
45944620
properties:

examples/v2/application-security/CreateApplicationSecurityWafCustomRule.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
min_length: 0,
3232
}),
3333
regex: "path.*",
34+
type: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionParametersType::STRING,
3435
value: "custom_tag",
3536
}),
3637
}),

features/v2/application_security.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ Feature: Application Security
1616
@generated @skip @team:DataDog/asm-backend
1717
Scenario: Create a WAF custom rule returns "Bad Request" response
1818
Given new "CreateApplicationSecurityWafCustomRule" request
19-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
19+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
2020
When the request is sent
2121
Then the response status is 400 Bad Request
2222

2323
@generated @skip @team:DataDog/asm-backend
2424
Scenario: Create a WAF custom rule returns "Concurrent Modification" response
2525
Given new "CreateApplicationSecurityWafCustomRule" request
26-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
26+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
2727
When the request is sent
2828
Then the response status is 409 Concurrent Modification
2929

3030
@generated @skip @team:DataDog/asm-backend
3131
Scenario: Create a WAF custom rule returns "Created" response
3232
Given new "CreateApplicationSecurityWafCustomRule" request
33-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
33+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
3434
When the request is sent
3535
Then the response status is 201 Created
3636

@@ -153,15 +153,15 @@ Feature: Application Security
153153
Scenario: Update a WAF Custom Rule returns "Concurrent Modification" response
154154
Given new "UpdateApplicationSecurityWafCustomRule" request
155155
And request contains "custom_rule_id" parameter from "REPLACE.ME"
156-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
156+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
157157
When the request is sent
158158
Then the response status is 409 Concurrent Modification
159159

160160
@generated @skip @team:DataDog/asm-backend
161161
Scenario: Update a WAF Custom Rule returns "Not Found" response
162162
Given new "UpdateApplicationSecurityWafCustomRule" request
163163
And request contains "custom_rule_id" parameter from "REPLACE.ME"
164-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
164+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
165165
When the request is sent
166166
Then the response status is 404 Not Found
167167

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ def overrides
11491149
"v2.application_security_waf_custom_rule_condition_operator" => "ApplicationSecurityWafCustomRuleConditionOperator",
11501150
"v2.application_security_waf_custom_rule_condition_options" => "ApplicationSecurityWafCustomRuleConditionOptions",
11511151
"v2.application_security_waf_custom_rule_condition_parameters" => "ApplicationSecurityWafCustomRuleConditionParameters",
1152+
"v2.application_security_waf_custom_rule_condition_parameters_type" => "ApplicationSecurityWafCustomRuleConditionParametersType",
11521153
"v2.application_security_waf_custom_rule_create_attributes" => "ApplicationSecurityWafCustomRuleCreateAttributes",
11531154
"v2.application_security_waf_custom_rule_create_data" => "ApplicationSecurityWafCustomRuleCreateData",
11541155
"v2.application_security_waf_custom_rule_create_request" => "ApplicationSecurityWafCustomRuleCreateRequest",

lib/datadog_api_client/v2/models/application_security_waf_custom_rule_condition_operator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ class ApplicationSecurityWafCustomRuleConditionOperator
3232
IP_MATCH = "ip_match".freeze
3333
NOT_IP_MATCH = "!ip_match".freeze
3434
CAPTURE_DATA = "capture_data".freeze
35+
EXISTS = "exists".freeze
36+
NOT_EXISTS = "!exists".freeze
37+
EQUALS = "equals".freeze
38+
NOT_EQUALS = "!equals".freeze
3539
end
3640
end

lib/datadog_api_client/v2/models/application_security_waf_custom_rule_condition_parameters.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class ApplicationSecurityWafCustomRuleConditionParameters
3737
# Regex to use with the condition. Only used with match_regex and !match_regex operator.
3838
attr_accessor :regex
3939

40+
# The type of the value to compare against. Only used with the equals and !equals operator.
41+
attr_accessor :type
42+
4043
# Store the captured value in the specified tag name. Only used with the capture_data operator.
4144
attr_accessor :value
4245

@@ -51,6 +54,7 @@ def self.attribute_map
5154
:'list' => :'list',
5255
:'options' => :'options',
5356
:'regex' => :'regex',
57+
:'type' => :'type',
5458
:'value' => :'value'
5559
}
5660
end
@@ -64,6 +68,7 @@ def self.openapi_types
6468
:'list' => :'Array<String>',
6569
:'options' => :'ApplicationSecurityWafCustomRuleConditionOptions',
6670
:'regex' => :'String',
71+
:'type' => :'ApplicationSecurityWafCustomRuleConditionParametersType',
6772
:'value' => :'String'
6873
}
6974
end
@@ -110,6 +115,10 @@ def initialize(attributes = {})
110115
self.regex = attributes[:'regex']
111116
end
112117

118+
if attributes.key?(:'type')
119+
self.type = attributes[:'type']
120+
end
121+
113122
if attributes.key?(:'value')
114123
self.value = attributes[:'value']
115124
end
@@ -164,6 +173,7 @@ def ==(o)
164173
list == o.list &&
165174
options == o.options &&
166175
regex == o.regex &&
176+
type == o.type &&
167177
value == o.value &&
168178
additional_properties == o.additional_properties
169179
end
@@ -172,7 +182,7 @@ def ==(o)
172182
# @return [Integer] Hash code
173183
# @!visibility private
174184
def hash
175-
[data, inputs, list, options, regex, value, additional_properties].hash
185+
[data, inputs, list, options, regex, type, value, additional_properties].hash
176186
end
177187
end
178188
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
Contact: support@datadoghq.com
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V2
20+
# The type of the value to compare against. Only used with the equals and !equals operator.
21+
class ApplicationSecurityWafCustomRuleConditionParametersType
22+
include BaseEnumModel
23+
24+
BOOLEAN = "boolean".freeze
25+
SIGNED = "signed".freeze
26+
UNSIGNED = "unsigned".freeze
27+
FLOAT = "float".freeze
28+
STRING = "string".freeze
29+
end
30+
end

0 commit comments

Comments
 (0)