Skip to content
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
26 changes: 26 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4338,6 +4338,10 @@ components:
- ip_match
- "!ip_match"
- capture_data
- exists
- "!exists"
- equals
- "!equals"
example: "match_regex"
type: string
x-enum-varnames:
Expand All @@ -4352,6 +4356,10 @@ components:
- IP_MATCH
- NOT_IP_MATCH
- CAPTURE_DATA
- EXISTS
- NOT_EXISTS
- EQUALS
- NOT_EQUALS
ApplicationSecurityWafCustomRuleConditionOptions:
description: Options for the operator of this condition.
properties:
Expand Down Expand Up @@ -4392,6 +4400,8 @@ components:
description: "Regex to use with the condition. Only used with match_regex and !match_regex operator."
example: "path.*"
type: string
type:
$ref: "#/components/schemas/ApplicationSecurityWafCustomRuleConditionParametersType"
value:
description: |-
Store the captured value in the specified tag name. Only used with the capture_data operator.
Expand All @@ -4400,6 +4410,22 @@ components:
required:
- inputs
type: object
ApplicationSecurityWafCustomRuleConditionParametersType:
description: The type of the value to compare against. Only used with the equals and !equals operator.
enum:
- boolean
- signed
- unsigned
- float
- string
example: "string"
type: string
x-enum-varnames:
- BOOLEAN
- SIGNED
- UNSIGNED
- FLOAT
- STRING
ApplicationSecurityWafCustomRuleCreateAttributes:
description: "Create a new WAF custom rule."
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionOperator;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionOptions;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionParameters;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionParametersType;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCreateAttributes;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCreateData;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCreateRequest;
Expand Down Expand Up @@ -62,6 +63,9 @@ public static void main(String[] args) {
.caseSensitive(false)
.minLength(0L))
.regex("path.*")
.type(
ApplicationSecurityWafCustomRuleConditionParametersType
.STRING)
.value("custom_tag"))))
.enabled(false)
.name("Block request from a bad useragent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public class ApplicationSecurityWafCustomRuleConditionOperator extends ModelEnum
"!exact_match",
"ip_match",
"!ip_match",
"capture_data"));
"capture_data",
"exists",
"!exists",
"equals",
"!equals"));

public static final ApplicationSecurityWafCustomRuleConditionOperator MATCH_REGEX =
new ApplicationSecurityWafCustomRuleConditionOperator("match_regex");
Expand All @@ -62,6 +66,14 @@ public class ApplicationSecurityWafCustomRuleConditionOperator extends ModelEnum
new ApplicationSecurityWafCustomRuleConditionOperator("!ip_match");
public static final ApplicationSecurityWafCustomRuleConditionOperator CAPTURE_DATA =
new ApplicationSecurityWafCustomRuleConditionOperator("capture_data");
public static final ApplicationSecurityWafCustomRuleConditionOperator EXISTS =
new ApplicationSecurityWafCustomRuleConditionOperator("exists");
public static final ApplicationSecurityWafCustomRuleConditionOperator NOT_EXISTS =
new ApplicationSecurityWafCustomRuleConditionOperator("!exists");
public static final ApplicationSecurityWafCustomRuleConditionOperator EQUALS =
new ApplicationSecurityWafCustomRuleConditionOperator("equals");
public static final ApplicationSecurityWafCustomRuleConditionOperator NOT_EQUALS =
new ApplicationSecurityWafCustomRuleConditionOperator("!equals");

ApplicationSecurityWafCustomRuleConditionOperator(String value) {
super(value, allowedValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
ApplicationSecurityWafCustomRuleConditionParameters.JSON_PROPERTY_LIST,
ApplicationSecurityWafCustomRuleConditionParameters.JSON_PROPERTY_OPTIONS,
ApplicationSecurityWafCustomRuleConditionParameters.JSON_PROPERTY_REGEX,
ApplicationSecurityWafCustomRuleConditionParameters.JSON_PROPERTY_TYPE,
ApplicationSecurityWafCustomRuleConditionParameters.JSON_PROPERTY_VALUE
})
@jakarta.annotation.Generated(
Expand All @@ -47,6 +48,9 @@ public class ApplicationSecurityWafCustomRuleConditionParameters {
public static final String JSON_PROPERTY_REGEX = "regex";
private String regex;

public static final String JSON_PROPERTY_TYPE = "type";
private ApplicationSecurityWafCustomRuleConditionParametersType type;

public static final String JSON_PROPERTY_VALUE = "value";
private String value;

Expand Down Expand Up @@ -186,6 +190,32 @@ public void setRegex(String regex) {
this.regex = regex;
}

public ApplicationSecurityWafCustomRuleConditionParameters type(
ApplicationSecurityWafCustomRuleConditionParametersType type) {
this.type = type;
this.unparsed |= !type.isValid();
return this;
}

/**
* The type of the value to compare against. Only used with the equals and !equals operator.
*
* @return type
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public ApplicationSecurityWafCustomRuleConditionParametersType getType() {
return type;
}

public void setType(ApplicationSecurityWafCustomRuleConditionParametersType type) {
if (!type.isValid()) {
this.unparsed = true;
}
this.type = type;
}

public ApplicationSecurityWafCustomRuleConditionParameters value(String value) {
this.value = value;
return this;
Expand Down Expand Up @@ -273,6 +303,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.list, applicationSecurityWafCustomRuleConditionParameters.list)
&& Objects.equals(this.options, applicationSecurityWafCustomRuleConditionParameters.options)
&& Objects.equals(this.regex, applicationSecurityWafCustomRuleConditionParameters.regex)
&& Objects.equals(this.type, applicationSecurityWafCustomRuleConditionParameters.type)
&& Objects.equals(this.value, applicationSecurityWafCustomRuleConditionParameters.value)
&& Objects.equals(
this.additionalProperties,
Expand All @@ -281,7 +312,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(data, inputs, list, options, regex, value, additionalProperties);
return Objects.hash(data, inputs, list, options, regex, type, value, additionalProperties);
}

@Override
Expand All @@ -293,6 +324,7 @@ public String toString() {
sb.append(" list: ").append(toIndentedString(list)).append("\n");
sb.append(" options: ").append(toIndentedString(options)).append("\n");
sb.append(" regex: ").append(toIndentedString(regex)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" value: ").append(toIndentedString(value)).append("\n");
sb.append(" additionalProperties: ")
.append(toIndentedString(additionalProperties))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

package com.datadog.api.client.v2.model;

import com.datadog.api.client.ModelEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/** The type of the value to compare against. Only used with the equals and !equals operator. */
@JsonSerialize(
using =
ApplicationSecurityWafCustomRuleConditionParametersType
.ApplicationSecurityWafCustomRuleConditionParametersTypeSerializer.class)
public class ApplicationSecurityWafCustomRuleConditionParametersType extends ModelEnum<String> {

private static final Set<String> allowedValues =
new HashSet<String>(Arrays.asList("boolean", "signed", "unsigned", "float", "string"));

public static final ApplicationSecurityWafCustomRuleConditionParametersType BOOLEAN =
new ApplicationSecurityWafCustomRuleConditionParametersType("boolean");
public static final ApplicationSecurityWafCustomRuleConditionParametersType SIGNED =
new ApplicationSecurityWafCustomRuleConditionParametersType("signed");
public static final ApplicationSecurityWafCustomRuleConditionParametersType UNSIGNED =
new ApplicationSecurityWafCustomRuleConditionParametersType("unsigned");
public static final ApplicationSecurityWafCustomRuleConditionParametersType FLOAT =
new ApplicationSecurityWafCustomRuleConditionParametersType("float");
public static final ApplicationSecurityWafCustomRuleConditionParametersType STRING =
new ApplicationSecurityWafCustomRuleConditionParametersType("string");

ApplicationSecurityWafCustomRuleConditionParametersType(String value) {
super(value, allowedValues);
}

public static class ApplicationSecurityWafCustomRuleConditionParametersTypeSerializer
extends StdSerializer<ApplicationSecurityWafCustomRuleConditionParametersType> {
public ApplicationSecurityWafCustomRuleConditionParametersTypeSerializer(
Class<ApplicationSecurityWafCustomRuleConditionParametersType> t) {
super(t);
}

public ApplicationSecurityWafCustomRuleConditionParametersTypeSerializer() {
this(null);
}

@Override
public void serialize(
ApplicationSecurityWafCustomRuleConditionParametersType value,
JsonGenerator jgen,
SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeObject(value.value);
}
}

@JsonCreator
public static ApplicationSecurityWafCustomRuleConditionParametersType fromValue(String value) {
return new ApplicationSecurityWafCustomRuleConditionParametersType(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ Feature: Application Security
@generated @skip @team:DataDog/asm-backend
Scenario: Create a WAF custom rule returns "Bad Request" response
Given new "CreateApplicationSecurityWafCustomRule" request
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"}}
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"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/asm-backend
Scenario: Create a WAF custom rule returns "Concurrent Modification" response
Given new "CreateApplicationSecurityWafCustomRule" request
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"}}
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"}}
When the request is sent
Then the response status is 409 Concurrent Modification

@generated @skip @team:DataDog/asm-backend
Scenario: Create a WAF custom rule returns "Created" response
Given new "CreateApplicationSecurityWafCustomRule" request
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"}}
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"}}
When the request is sent
Then the response status is 201 Created

Expand Down Expand Up @@ -153,15 +153,15 @@ Feature: Application Security
Scenario: Update a WAF Custom Rule returns "Concurrent Modification" response
Given new "UpdateApplicationSecurityWafCustomRule" request
And request contains "custom_rule_id" parameter from "REPLACE.ME"
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"}}
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"}}
When the request is sent
Then the response status is 409 Concurrent Modification

@generated @skip @team:DataDog/asm-backend
Scenario: Update a WAF Custom Rule returns "Not Found" response
Given new "UpdateApplicationSecurityWafCustomRule" request
And request contains "custom_rule_id" parameter from "REPLACE.ME"
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"}}
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"}}
When the request is sent
Then the response status is 404 Not Found

Expand Down
Loading