software.amazon.awssdk.services.waf.model.XssMatchTuple Maven / Gradle / Ivy
Show all versions of waf Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.waf.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
*
* This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the
* developer guide.
*
*
* For the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the
* latest version, AWS WAF has a single set of endpoints for regional and global use.
*
*
*
* Specifies the part of a web request that you want AWS WAF to inspect for cross-site scripting attacks and, if you
* want AWS WAF to inspect a header, the name of the header.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class XssMatchTuple implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField FIELD_TO_MATCH_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("FieldToMatch").getter(getter(XssMatchTuple::fieldToMatch)).setter(setter(Builder::fieldToMatch))
.constructor(FieldToMatch::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FieldToMatch").build()).build();
private static final SdkField TEXT_TRANSFORMATION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TextTransformation").getter(getter(XssMatchTuple::textTransformationAsString))
.setter(setter(Builder::textTransformation))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TextTransformation").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FIELD_TO_MATCH_FIELD,
TEXT_TRANSFORMATION_FIELD));
private static final long serialVersionUID = 1L;
private final FieldToMatch fieldToMatch;
private final String textTransformation;
private XssMatchTuple(BuilderImpl builder) {
this.fieldToMatch = builder.fieldToMatch;
this.textTransformation = builder.textTransformation;
}
/**
*
* Specifies where in a web request to look for cross-site scripting attacks.
*
*
* @return Specifies where in a web request to look for cross-site scripting attacks.
*/
public final FieldToMatch fieldToMatch() {
return fieldToMatch;
}
/**
*
* Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to
* bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch
* before inspecting it for a match.
*
*
* You can only specify a single type of TextTransformation.
*
*
* CMD_LINE
*
*
* When you're concerned that attackers are injecting an operating system command line command and using unusual
* formatting to disguise some or all of the command, use this option to perform the following transformations:
*
*
* -
*
* Delete the following characters: \ " ' ^
*
*
* -
*
* Delete spaces before the following characters: / (
*
*
* -
*
* Replace the following characters with a space: , ;
*
*
* -
*
* Replace multiple spaces with one space
*
*
* -
*
* Convert uppercase letters (A-Z) to lowercase (a-z)
*
*
*
*
* COMPRESS_WHITE_SPACE
*
*
* Use this option to replace the following characters with a space character (decimal 32):
*
*
* -
*
* \f, formfeed, decimal 12
*
*
* -
*
* \t, tab, decimal 9
*
*
* -
*
* \n, newline, decimal 10
*
*
* -
*
* \r, carriage return, decimal 13
*
*
* -
*
* \v, vertical tab, decimal 11
*
*
* -
*
* non-breaking space, decimal 160
*
*
*
*
* COMPRESS_WHITE_SPACE
also replaces multiple spaces with one space.
*
*
* HTML_ENTITY_DECODE
*
*
* Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE
* performs the following operations:
*
*
* -
*
* Replaces (ampersand)quot;
with "
*
*
* -
*
* Replaces (ampersand)nbsp;
with a non-breaking space, decimal 160
*
*
* -
*
* Replaces (ampersand)lt;
with a "less than" symbol
*
*
* -
*
* Replaces (ampersand)gt;
with >
*
*
* -
*
* Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh;
, with the
* corresponding characters
*
*
* -
*
* Replaces characters that are represented in decimal format, (ampersand)#nnnn;
, with the
* corresponding characters
*
*
*
*
* LOWERCASE
*
*
* Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
*
*
* URL_DECODE
*
*
* Use this option to decode a URL-encoded value.
*
*
* NONE
*
*
* Specify NONE
if you don't want to perform any text transformations.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #textTransformation} will return {@link TextTransformation#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #textTransformationAsString}.
*
*
* @return Text transformations eliminate some of the unusual formatting that attackers use in web requests in an
* effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on
* FieldToMatch
before inspecting it for a match.
*
* You can only specify a single type of TextTransformation.
*
*
* CMD_LINE
*
*
* When you're concerned that attackers are injecting an operating system command line command and using
* unusual formatting to disguise some or all of the command, use this option to perform the following
* transformations:
*
*
* -
*
* Delete the following characters: \ " ' ^
*
*
* -
*
* Delete spaces before the following characters: / (
*
*
* -
*
* Replace the following characters with a space: , ;
*
*
* -
*
* Replace multiple spaces with one space
*
*
* -
*
* Convert uppercase letters (A-Z) to lowercase (a-z)
*
*
*
*
* COMPRESS_WHITE_SPACE
*
*
* Use this option to replace the following characters with a space character (decimal 32):
*
*
* -
*
* \f, formfeed, decimal 12
*
*
* -
*
* \t, tab, decimal 9
*
*
* -
*
* \n, newline, decimal 10
*
*
* -
*
* \r, carriage return, decimal 13
*
*
* -
*
* \v, vertical tab, decimal 11
*
*
* -
*
* non-breaking space, decimal 160
*
*
*
*
* COMPRESS_WHITE_SPACE
also replaces multiple spaces with one space.
*
*
* HTML_ENTITY_DECODE
*
*
* Use this option to replace HTML-encoded characters with unencoded characters.
* HTML_ENTITY_DECODE
performs the following operations:
*
*
* -
*
* Replaces (ampersand)quot;
with "
*
*
* -
*
* Replaces (ampersand)nbsp;
with a non-breaking space, decimal 160
*
*
* -
*
* Replaces (ampersand)lt;
with a "less than" symbol
*
*
* -
*
* Replaces (ampersand)gt;
with >
*
*
* -
*
* Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh;
, with the
* corresponding characters
*
*
* -
*
* Replaces characters that are represented in decimal format, (ampersand)#nnnn;
, with the
* corresponding characters
*
*
*
*
* LOWERCASE
*
*
* Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
*
*
* URL_DECODE
*
*
* Use this option to decode a URL-encoded value.
*
*
* NONE
*
*
* Specify NONE
if you don't want to perform any text transformations.
* @see TextTransformation
*/
public final TextTransformation textTransformation() {
return TextTransformation.fromValue(textTransformation);
}
/**
*
* Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to
* bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on FieldToMatch
* before inspecting it for a match.
*
*
* You can only specify a single type of TextTransformation.
*
*
* CMD_LINE
*
*
* When you're concerned that attackers are injecting an operating system command line command and using unusual
* formatting to disguise some or all of the command, use this option to perform the following transformations:
*
*
* -
*
* Delete the following characters: \ " ' ^
*
*
* -
*
* Delete spaces before the following characters: / (
*
*
* -
*
* Replace the following characters with a space: , ;
*
*
* -
*
* Replace multiple spaces with one space
*
*
* -
*
* Convert uppercase letters (A-Z) to lowercase (a-z)
*
*
*
*
* COMPRESS_WHITE_SPACE
*
*
* Use this option to replace the following characters with a space character (decimal 32):
*
*
* -
*
* \f, formfeed, decimal 12
*
*
* -
*
* \t, tab, decimal 9
*
*
* -
*
* \n, newline, decimal 10
*
*
* -
*
* \r, carriage return, decimal 13
*
*
* -
*
* \v, vertical tab, decimal 11
*
*
* -
*
* non-breaking space, decimal 160
*
*
*
*
* COMPRESS_WHITE_SPACE
also replaces multiple spaces with one space.
*
*
* HTML_ENTITY_DECODE
*
*
* Use this option to replace HTML-encoded characters with unencoded characters. HTML_ENTITY_DECODE
* performs the following operations:
*
*
* -
*
* Replaces (ampersand)quot;
with "
*
*
* -
*
* Replaces (ampersand)nbsp;
with a non-breaking space, decimal 160
*
*
* -
*
* Replaces (ampersand)lt;
with a "less than" symbol
*
*
* -
*
* Replaces (ampersand)gt;
with >
*
*
* -
*
* Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh;
, with the
* corresponding characters
*
*
* -
*
* Replaces characters that are represented in decimal format, (ampersand)#nnnn;
, with the
* corresponding characters
*
*
*
*
* LOWERCASE
*
*
* Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
*
*
* URL_DECODE
*
*
* Use this option to decode a URL-encoded value.
*
*
* NONE
*
*
* Specify NONE
if you don't want to perform any text transformations.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #textTransformation} will return {@link TextTransformation#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #textTransformationAsString}.
*
*
* @return Text transformations eliminate some of the unusual formatting that attackers use in web requests in an
* effort to bypass AWS WAF. If you specify a transformation, AWS WAF performs the transformation on
* FieldToMatch
before inspecting it for a match.
*
* You can only specify a single type of TextTransformation.
*
*
* CMD_LINE
*
*
* When you're concerned that attackers are injecting an operating system command line command and using
* unusual formatting to disguise some or all of the command, use this option to perform the following
* transformations:
*
*
* -
*
* Delete the following characters: \ " ' ^
*
*
* -
*
* Delete spaces before the following characters: / (
*
*
* -
*
* Replace the following characters with a space: , ;
*
*
* -
*
* Replace multiple spaces with one space
*
*
* -
*
* Convert uppercase letters (A-Z) to lowercase (a-z)
*
*
*
*
* COMPRESS_WHITE_SPACE
*
*
* Use this option to replace the following characters with a space character (decimal 32):
*
*
* -
*
* \f, formfeed, decimal 12
*
*
* -
*
* \t, tab, decimal 9
*
*
* -
*
* \n, newline, decimal 10
*
*
* -
*
* \r, carriage return, decimal 13
*
*
* -
*
* \v, vertical tab, decimal 11
*
*
* -
*
* non-breaking space, decimal 160
*
*
*
*
* COMPRESS_WHITE_SPACE
also replaces multiple spaces with one space.
*
*
* HTML_ENTITY_DECODE
*
*
* Use this option to replace HTML-encoded characters with unencoded characters.
* HTML_ENTITY_DECODE
performs the following operations:
*
*
* -
*
* Replaces (ampersand)quot;
with "
*
*
* -
*
* Replaces (ampersand)nbsp;
with a non-breaking space, decimal 160
*
*
* -
*
* Replaces (ampersand)lt;
with a "less than" symbol
*
*
* -
*
* Replaces (ampersand)gt;
with >
*
*
* -
*
* Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh;
, with the
* corresponding characters
*
*
* -
*
* Replaces characters that are represented in decimal format, (ampersand)#nnnn;
, with the
* corresponding characters
*
*
*
*
* LOWERCASE
*
*
* Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
*
*
* URL_DECODE
*
*
* Use this option to decode a URL-encoded value.
*
*
* NONE
*
*
* Specify NONE
if you don't want to perform any text transformations.
* @see TextTransformation
*/
public final String textTransformationAsString() {
return textTransformation;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(fieldToMatch());
hashCode = 31 * hashCode + Objects.hashCode(textTransformationAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof XssMatchTuple)) {
return false;
}
XssMatchTuple other = (XssMatchTuple) obj;
return Objects.equals(fieldToMatch(), other.fieldToMatch())
&& Objects.equals(textTransformationAsString(), other.textTransformationAsString());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("XssMatchTuple").add("FieldToMatch", fieldToMatch())
.add("TextTransformation", textTransformationAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FieldToMatch":
return Optional.ofNullable(clazz.cast(fieldToMatch()));
case "TextTransformation":
return Optional.ofNullable(clazz.cast(textTransformationAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* You can only specify a single type of TextTransformation.
*
*
* CMD_LINE
*
*
* When you're concerned that attackers are injecting an operating system command line command and using
* unusual formatting to disguise some or all of the command, use this option to perform the following
* transformations:
*
*
* -
*
* Delete the following characters: \ " ' ^
*
*
* -
*
* Delete spaces before the following characters: / (
*
*
* -
*
* Replace the following characters with a space: , ;
*
*
* -
*
* Replace multiple spaces with one space
*
*
* -
*
* Convert uppercase letters (A-Z) to lowercase (a-z)
*
*
*
*
* COMPRESS_WHITE_SPACE
*
*
* Use this option to replace the following characters with a space character (decimal 32):
*
*
* -
*
* \f, formfeed, decimal 12
*
*
* -
*
* \t, tab, decimal 9
*
*
* -
*
* \n, newline, decimal 10
*
*
* -
*
* \r, carriage return, decimal 13
*
*
* -
*
* \v, vertical tab, decimal 11
*
*
* -
*
* non-breaking space, decimal 160
*
*
*
*
* COMPRESS_WHITE_SPACE
also replaces multiple spaces with one space.
*
*
* HTML_ENTITY_DECODE
*
*
* Use this option to replace HTML-encoded characters with unencoded characters.
* HTML_ENTITY_DECODE
performs the following operations:
*
*
* -
*
* Replaces (ampersand)quot;
with "
*
*
* -
*
* Replaces (ampersand)nbsp;
with a non-breaking space, decimal 160
*
*
* -
*
* Replaces (ampersand)lt;
with a "less than" symbol
*
*
* -
*
* Replaces (ampersand)gt;
with >
*
*
* -
*
* Replaces characters that are represented in hexadecimal format, (ampersand)#xhhhh;
, with
* the corresponding characters
*
*
* -
*
* Replaces characters that are represented in decimal format, (ampersand)#nnnn;
, with the
* corresponding characters
*
*
*
*
* LOWERCASE
*
*
* Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
*
*
* URL_DECODE
*
*
* Use this option to decode a URL-encoded value.
*
*
* NONE
*
*
* Specify NONE
if you don't want to perform any text transformations.
* @see TextTransformation
* @return Returns a reference to this object so that method calls can be chained together.
* @see TextTransformation
*/
Builder textTransformation(TextTransformation textTransformation);
}
static final class BuilderImpl implements Builder {
private FieldToMatch fieldToMatch;
private String textTransformation;
private BuilderImpl() {
}
private BuilderImpl(XssMatchTuple model) {
fieldToMatch(model.fieldToMatch);
textTransformation(model.textTransformation);
}
public final FieldToMatch.Builder getFieldToMatch() {
return fieldToMatch != null ? fieldToMatch.toBuilder() : null;
}
public final void setFieldToMatch(FieldToMatch.BuilderImpl fieldToMatch) {
this.fieldToMatch = fieldToMatch != null ? fieldToMatch.build() : null;
}
@Override
public final Builder fieldToMatch(FieldToMatch fieldToMatch) {
this.fieldToMatch = fieldToMatch;
return this;
}
public final String getTextTransformation() {
return textTransformation;
}
public final void setTextTransformation(String textTransformation) {
this.textTransformation = textTransformation;
}
@Override
public final Builder textTransformation(String textTransformation) {
this.textTransformation = textTransformation;
return this;
}
@Override
public final Builder textTransformation(TextTransformation textTransformation) {
this.textTransformation(textTransformation == null ? null : textTransformation.toString());
return this;
}
@Override
public XssMatchTuple build() {
return new XssMatchTuple(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}