AWS WAF

2018/08/31 - AWS WAF - 4 new 15 updated api methods

Changes  This change includes support for the WAF FullLogging feature through which Customers will have access to all the logs of requests that are inspected by a WAF WebACL. The new APIs allow Customers to manage association of a WebACL with one or more supported "LogDestination" and redact any request fields from the logs.

DeleteLoggingConfiguration (new) Link ¶

Permanently deletes the LoggingConfiguration from the specified web ACL.

See also: AWS API Documentation

Request Syntax

client.delete_logging_configuration(
    ResourceArn='string'
)
type ResourceArn

string

param ResourceArn

[REQUIRED]

The Amazon Resource Name (ARN) of the web ACL from which you want to delete the LoggingConfiguration.

rtype

dict

returns

Response Syntax

{}

Response Structure

  • (dict) --

ListLoggingConfigurations (new) Link ¶

Returns an array of LoggingConfiguration objects.

See also: AWS API Documentation

Request Syntax

client.list_logging_configurations(
    NextMarker='string',
    Limit=123
)
type NextMarker

string

param NextMarker

If you specify a value for Limit and you have more LoggingConfigurations than the value of Limit , AWS WAF returns a NextMarker value in the response that allows you to list another group of LoggingConfigurations . For the second and subsequent ListLoggingConfigurations requests, specify the value of NextMarker from the previous response to get information about another batch of ListLoggingConfigurations .

type Limit

integer

param Limit

Specifies the number of LoggingConfigurations that you want AWS WAF to return for this request. If you have more LoggingConfigurations than the number that you specify for Limit , the response includes a NextMarker value that you can use to get another batch of LoggingConfigurations .

rtype

dict

returns

Response Syntax

{
    'LoggingConfigurations': [
        {
            'ResourceArn': 'string',
            'LogDestinationConfigs': [
                'string',
            ],
            'RedactedFields': [
                {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
            ]
        },
    ],
    'NextMarker': 'string'
}

Response Structure

  • (dict) --

    • LoggingConfigurations (list) --

      An array of LoggingConfiguration objects.

      • (dict) --

        The Amazon Kinesis Data Firehose delivery streams, RedactedFields information, and the web ACL Amazon Resource Name (ARN).

        • ResourceArn (string) --

          The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .

        • LogDestinationConfigs (list) --

          An array of Amazon Kinesis Data Firehose delivery stream ARNs.

          • (string) --

        • RedactedFields (list) --

          The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the delivery stream will be xxx .

          • (dict) --

            Specifies where in a web request to look for TargetString .

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

    • NextMarker (string) --

      If you have more LoggingConfigurations than the number that you specified for Limit in the request, the response includes a NextMarker value. To list more LoggingConfigurations , submit another ListLoggingConfigurations request, and specify the NextMarker value from the response in the NextMarker value in the next request.

PutLoggingConfiguration (new) Link ¶

Associates a LoggingConfiguration with a specified web ACL.

You can access information about all traffic that AWS WAF inspects using the following steps:

When you successfully enable logging using a PutLoggingConfiguration request, AWS WAF will create a service linked role with the necessary permissions to write logs to the Amazon Kinesis Data Firehose delivery stream. For more information, see Logging Web ACL Traffic Information in the AWS WAF Developer Guide .

See also: AWS API Documentation

Request Syntax

client.put_logging_configuration(
    LoggingConfiguration={
        'ResourceArn': 'string',
        'LogDestinationConfigs': [
            'string',
        ],
        'RedactedFields': [
            {
                'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                'Data': 'string'
            },
        ]
    }
)
type LoggingConfiguration

dict

param LoggingConfiguration

[REQUIRED]

The Amazon Kinesis Data Firehose delivery streams that contains the inspected traffic information, the redacted fields details, and the Amazon Resource Name (ARN) of the web ACL to monitor.

  • ResourceArn (string) -- [REQUIRED]

    The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .

  • LogDestinationConfigs (list) -- [REQUIRED]

    An array of Amazon Kinesis Data Firehose delivery stream ARNs.

    • (string) --

  • RedactedFields (list) --

    The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the delivery stream will be xxx .

    • (dict) --

      Specifies where in a web request to look for TargetString .

      • Type (string) -- [REQUIRED]

        The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

        • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

        • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

        • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

        • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

        • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

        • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

        • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

      • Data (string) --

        When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

        When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

        If the value of Type is any other value, omit Data .

rtype

dict

returns

Response Syntax

{
    'LoggingConfiguration': {
        'ResourceArn': 'string',
        'LogDestinationConfigs': [
            'string',
        ],
        'RedactedFields': [
            {
                'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                'Data': 'string'
            },
        ]
    }
}

Response Structure

  • (dict) --

    • LoggingConfiguration (dict) --

      The LoggingConfiguration that you submitted in the request.

      • ResourceArn (string) --

        The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .

      • LogDestinationConfigs (list) --

        An array of Amazon Kinesis Data Firehose delivery stream ARNs.

        • (string) --

      • RedactedFields (list) --

        The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the delivery stream will be xxx .

        • (dict) --

          Specifies where in a web request to look for TargetString .

          • Type (string) --

            The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

            • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

            • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

            • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

            • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

            • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

            • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

            • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

          • Data (string) --

            When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

            When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

            If the value of Type is any other value, omit Data .

GetLoggingConfiguration (new) Link ¶

Returns the LoggingConfiguration for the specified web ACL.

See also: AWS API Documentation

Request Syntax

client.get_logging_configuration(
    ResourceArn='string'
)
type ResourceArn

string

param ResourceArn

[REQUIRED]

The Amazon Resource Name (ARN) of the web ACL for which you want to get the LoggingConfiguration.

rtype

dict

returns

Response Syntax

{
    'LoggingConfiguration': {
        'ResourceArn': 'string',
        'LogDestinationConfigs': [
            'string',
        ],
        'RedactedFields': [
            {
                'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                'Data': 'string'
            },
        ]
    }
}

Response Structure

  • (dict) --

    • LoggingConfiguration (dict) --

      The LoggingConfiguration for the specified web ACL.

      • ResourceArn (string) --

        The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs .

      • LogDestinationConfigs (list) --

        An array of Amazon Kinesis Data Firehose delivery stream ARNs.

        • (string) --

      • RedactedFields (list) --

        The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the delivery stream will be xxx .

        • (dict) --

          Specifies where in a web request to look for TargetString .

          • Type (string) --

            The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

            • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

            • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

            • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

            • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

            • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

            • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

            • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

          • Data (string) --

            When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

            When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

            If the value of Type is any other value, omit Data .

CreateByteMatchSet (updated) Link ¶
Changes (response)
{'ByteMatchSet': {'ByteMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                'SINGLE_QUERY_ARG'}}}}}

Creates a ByteMatchSet . You then use UpdateByteMatchSet to identify the part of a web request that you want AWS WAF to inspect, such as the values of the User-Agent header or the query string. For example, you can create a ByteMatchSet that matches any requests with User-Agent headers that contain the string BadBot . You can then configure AWS WAF to reject those requests.

To create and configure a ByteMatchSet , perform the following steps:

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateByteMatchSet request.

  • Submit a CreateByteMatchSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateByteMatchSet request.

  • Submit an UpdateByteMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.create_byte_match_set(
    Name='string',
    ChangeToken='string'
)
type Name

string

param Name

[REQUIRED]

A friendly name or description of the ByteMatchSet. You can't change Name after you create a ByteMatchSet .

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

rtype

dict

returns

Response Syntax

{
    'ByteMatchSet': {
        'ByteMatchSetId': 'string',
        'Name': 'string',
        'ByteMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TargetString': b'bytes',
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
            },
        ]
    },
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    • ByteMatchSet (dict) --

      A ByteMatchSet that contains no ByteMatchTuple objects.

      • ByteMatchSetId (string) --

        The ByteMatchSetId for a ByteMatchSet . You use ByteMatchSetId to get information about a ByteMatchSet (see GetByteMatchSet ), update a ByteMatchSet (see UpdateByteMatchSet ), insert a ByteMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a ByteMatchSet from AWS WAF (see DeleteByteMatchSet ).

        ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets.

      • Name (string) --

        A friendly name or description of the ByteMatchSet. You can't change Name after you create a ByteMatchSet .

      • ByteMatchTuples (list) --

        Specifies the bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.

        • (dict) --

          The bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.

          • FieldToMatch (dict) --

            The part of a web request that you want AWS WAF to search, such as a specified header or a query string. For more information, see FieldToMatch.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TargetString (bytes) --

            The value that you want AWS WAF to search for. AWS WAF searches for the specified string in the part of web requests that you specified in FieldToMatch . The maximum length of the value is 50 bytes.

            Valid values depend on the values that you specified for FieldToMatch :

            • HEADER : The value that you want AWS WAF to search for in the request header that you specified in FieldToMatch, for example, the value of the User-Agent or Referer header.

            • METHOD : The HTTP method, which indicates the type of operation specified in the request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

            • QUERY_STRING : The value that you want AWS WAF to search for in the query string, which is the part of a URL that appears after a ? character.

            • URI : The value that you want AWS WAF to search for in the part of a URL that identifies a resource, for example, /images/daily-ad.jpg .

            • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

            • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

            • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but instead of inspecting a single parameter, AWS WAF inspects all parameters within the query string for the value or regex pattern that you specify in TargetString .

            If TargetString includes alphabetic characters A-Z and a-z, note that the value is case sensitive.

            If you're using the AWS WAF API

            Specify a base64-encoded version of the value. The maximum length of the value before you base64-encode it is 50 bytes.

            For example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you base64-encode BadBot using MIME base64 encoding and include the resulting value, QmFkQm90 , in the value of TargetString .

            If you're using the AWS CLI or one of the AWS SDKs

            The value that you want AWS WAF to search for. The SDK automatically base64 encodes the value.

          • TextTransformation (string) --

            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 TargetString before inspecting a request 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.

          • PositionalConstraint (string) --

            Within the portion of a web request that you want to search (for example, in the query string, if any), specify where you want AWS WAF to search. Valid values include the following:

            CONTAINS

            The specified part of the web request must include the value of TargetString , but the location doesn't matter.

            CONTAINS_WORD

            The specified part of the web request must include the value of TargetString , and TargetString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, TargetString must be a word, which means one of the following:

            • TargetString exactly matches the value of the specified part of the web request, such as the value of a header.

            • TargetString is at the beginning of the specified part of the web request and is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; .

            • TargetString is at the end of the specified part of the web request and is preceded by a character other than an alphanumeric character or underscore (_), for example, ;BadBot .

            • TargetString is in the middle of the specified part of the web request and is preceded and followed by characters other than alphanumeric characters or underscore (_), for example, -BadBot; .

            EXACTLY

            The value of the specified part of the web request must exactly match the value of TargetString .

            STARTS_WITH

            The value of TargetString must appear at the beginning of the specified part of the web request.

            ENDS_WITH

            The value of TargetString must appear at the end of the specified part of the web request.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the CreateByteMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

CreateRegexMatchSet (updated) Link ¶
Changes (response)
{'RegexMatchSet': {'RegexMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                  'SINGLE_QUERY_ARG'}}}}}

Creates a RegexMatchSet. You then use UpdateRegexMatchSet to identify the part of a web request that you want AWS WAF to inspect, such as the values of the User-Agent header or the query string. For example, you can create a RegexMatchSet that contains a RegexMatchTuple that looks for any requests with User-Agent headers that match a RegexPatternSet with pattern B[a@]dB[o0]t . You can then configure AWS WAF to reject those requests.

To create and configure a RegexMatchSet , perform the following steps:

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateRegexMatchSet request.

  • Submit a CreateRegexMatchSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateRegexMatchSet request.

  • Submit an UpdateRegexMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value, using a RegexPatternSet , that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.create_regex_match_set(
    Name='string',
    ChangeToken='string'
)
type Name

string

param Name

[REQUIRED]

A friendly name or description of the RegexMatchSet. You can't change Name after you create a RegexMatchSet .

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

rtype

dict

returns

Response Syntax

{
    'RegexMatchSet': {
        'RegexMatchSetId': 'string',
        'Name': 'string',
        'RegexMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'RegexPatternSetId': 'string'
            },
        ]
    },
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    • RegexMatchSet (dict) --

      A RegexMatchSet that contains no RegexMatchTuple objects.

      • RegexMatchSetId (string) --

        The RegexMatchSetId for a RegexMatchSet . You use RegexMatchSetId to get information about a RegexMatchSet (see GetRegexMatchSet ), update a RegexMatchSet (see UpdateRegexMatchSet ), insert a RegexMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a RegexMatchSet from AWS WAF (see DeleteRegexMatchSet ).

        RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets.

      • Name (string) --

        A friendly name or description of the RegexMatchSet. You can't change Name after you create a RegexMatchSet .

      • RegexMatchTuples (list) --

        Contains an array of RegexMatchTuple objects. Each RegexMatchTuple object contains:

        • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

        • The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet.

        • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

        • (dict) --

          The regular expression pattern that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings. Each RegexMatchTuple object contains:

          • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

          • The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet.

          • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for the RegexPatternSet .

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 RegexPatternSet before inspecting a request 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 commandline 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.

          • RegexPatternSetId (string) --

            The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet (see GetRegexPatternSet ), update a RegexPatternSet (see UpdateRegexPatternSet ), insert a RegexPatternSet into a RegexMatchSet or delete one from a RegexMatchSet (see UpdateRegexMatchSet ), and delete an RegexPatternSet from AWS WAF (see DeleteRegexPatternSet ).

            RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the CreateRegexMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

CreateSizeConstraintSet (updated) Link ¶
Changes (response)
{'SizeConstraintSet': {'SizeConstraints': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                     'SINGLE_QUERY_ARG'}}}}}

Creates a SizeConstraintSet . You then use UpdateSizeConstraintSet to identify the part of a web request that you want AWS WAF to check for length, such as the length of the User-Agent header or the length of the query string. For example, you can create a SizeConstraintSet that matches any requests that have a query string that is longer than 100 bytes. You can then configure AWS WAF to reject those requests.

To create and configure a SizeConstraintSet , perform the following steps:

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateSizeConstraintSet request.

  • Submit a CreateSizeConstraintSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateSizeConstraintSet request.

  • Submit an UpdateSizeConstraintSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.create_size_constraint_set(
    Name='string',
    ChangeToken='string'
)
type Name

string

param Name

[REQUIRED]

A friendly name or description of the SizeConstraintSet. You can't change Name after you create a SizeConstraintSet .

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

rtype

dict

returns

Response Syntax

{
    'SizeConstraintSet': {
        'SizeConstraintSetId': 'string',
        'Name': 'string',
        'SizeConstraints': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
                'Size': 123
            },
        ]
    },
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    • SizeConstraintSet (dict) --

      A SizeConstraintSet that contains no SizeConstraint objects.

      • SizeConstraintSetId (string) --

        A unique identifier for a SizeConstraintSet . You use SizeConstraintSetId to get information about a SizeConstraintSet (see GetSizeConstraintSet ), update a SizeConstraintSet (see UpdateSizeConstraintSet ), insert a SizeConstraintSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SizeConstraintSet from AWS WAF (see DeleteSizeConstraintSet ).

        SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets.

      • Name (string) --

        The name, if any, of the SizeConstraintSet .

      • SizeConstraints (list) --

        Specifies the parts of web requests that you want to inspect the size of.

        • (dict) --

          Specifies a constraint on the size of a part of the web request. AWS WAF uses the Size , ComparisonOperator , and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for the size constraint.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 a request for a match.

            You can only specify a single type of TextTransformation.

            Note that if you choose BODY for the value of Type , you must choose NONE for TextTransformation because CloudFront forwards only the first 8192 bytes for inspection.

            NONE

            Specify NONE if you don't want to perform any text transformations.

            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.

          • ComparisonOperator (string) --

            The type of comparison you want AWS WAF to perform. AWS WAF uses this in combination with the provided Size and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

            EQ : Used to test if the Size is equal to the size of the FieldToMatch

            NE : Used to test if the Size is not equal to the size of the FieldToMatch

            LE : Used to test if the Size is less than or equal to the size of the FieldToMatch

            LT : Used to test if the Size is strictly less than the size of the FieldToMatch

            GE : Used to test if the Size is greater than or equal to the size of the FieldToMatch

            GT : Used to test if the Size is strictly greater than the size of the FieldToMatch

          • Size (integer) --

            The size in bytes that you want AWS WAF to compare against the size of the specified FieldToMatch . AWS WAF uses this in combination with ComparisonOperator and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

            Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).

            If you specify URI for the value of Type , the / in the URI counts as one character. For example, the URI /logo.jpg is nine characters long.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the CreateSizeConstraintSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

CreateSqlInjectionMatchSet (updated) Link ¶
Changes (response)
{'SqlInjectionMatchSet': {'SqlInjectionMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                                'SINGLE_QUERY_ARG'}}}}}

Creates a SqlInjectionMatchSet, which you use to allow, block, or count requests that contain snippets of SQL code in a specified part of web requests. AWS WAF searches for character sequences that are likely to be malicious strings.

To create and configure a SqlInjectionMatchSet , perform the following steps:

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateSqlInjectionMatchSet request.

  • Submit a CreateSqlInjectionMatchSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateSqlInjectionMatchSet request.

  • Submit an UpdateSqlInjectionMatchSet request to specify the parts of web requests in which you want to allow, block, or count malicious SQL code.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.create_sql_injection_match_set(
    Name='string',
    ChangeToken='string'
)
type Name

string

param Name

[REQUIRED]

A friendly name or description for the SqlInjectionMatchSet that you're creating. You can't change Name after you create the SqlInjectionMatchSet .

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

rtype

dict

returns

Response Syntax

{
    'SqlInjectionMatchSet': {
        'SqlInjectionMatchSetId': 'string',
        'Name': 'string',
        'SqlInjectionMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
            },
        ]
    },
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    The response to a CreateSqlInjectionMatchSet request.

    • SqlInjectionMatchSet (dict) --

      A SqlInjectionMatchSet.

      • SqlInjectionMatchSetId (string) --

        A unique identifier for a SqlInjectionMatchSet . You use SqlInjectionMatchSetId to get information about a SqlInjectionMatchSet (see GetSqlInjectionMatchSet ), update a SqlInjectionMatchSet (see UpdateSqlInjectionMatchSet ), insert a SqlInjectionMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SqlInjectionMatchSet from AWS WAF (see DeleteSqlInjectionMatchSet ).

        SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets.

      • Name (string) --

        The name, if any, of the SqlInjectionMatchSet .

      • SqlInjectionMatchTuples (list) --

        Specifies the parts of web requests that you want to inspect for snippets of malicious SQL code.

        • (dict) --

          Specifies the part of a web request that you want AWS WAF to inspect for snippets of malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for snippets of malicious SQL code.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 a request 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.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the CreateSqlInjectionMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

CreateXssMatchSet (updated) Link ¶
Changes (response)
{'XssMatchSet': {'XssMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                              'SINGLE_QUERY_ARG'}}}}}

Creates an XssMatchSet, which you use to allow, block, or count requests that contain cross-site scripting attacks in the specified part of web requests. AWS WAF searches for character sequences that are likely to be malicious strings.

To create and configure an XssMatchSet , perform the following steps:

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateXssMatchSet request.

  • Submit a CreateXssMatchSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateXssMatchSet request.

  • Submit an UpdateXssMatchSet request to specify the parts of web requests in which you want to allow, block, or count cross-site scripting attacks.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.create_xss_match_set(
    Name='string',
    ChangeToken='string'
)
type Name

string

param Name

[REQUIRED]

A friendly name or description for the XssMatchSet that you're creating. You can't change Name after you create the XssMatchSet .

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

rtype

dict

returns

Response Syntax

{
    'XssMatchSet': {
        'XssMatchSetId': 'string',
        'Name': 'string',
        'XssMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
            },
        ]
    },
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    The response to a CreateXssMatchSet request.

    • XssMatchSet (dict) --

      An XssMatchSet.

      • XssMatchSetId (string) --

        A unique identifier for an XssMatchSet . You use XssMatchSetId to get information about an XssMatchSet (see GetXssMatchSet ), update an XssMatchSet (see UpdateXssMatchSet ), insert an XssMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an XssMatchSet from AWS WAF (see DeleteXssMatchSet ).

        XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets.

      • Name (string) --

        The name, if any, of the XssMatchSet .

      • XssMatchTuples (list) --

        Specifies the parts of web requests that you want to inspect for cross-site scripting attacks.

        • (dict) --

          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.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for cross-site scripting attacks.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 a request 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.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the CreateXssMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

GetByteMatchSet (updated) Link ¶
Changes (response)
{'ByteMatchSet': {'ByteMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                'SINGLE_QUERY_ARG'}}}}}

Returns the ByteMatchSet specified by ByteMatchSetId .

See also: AWS API Documentation

Request Syntax

client.get_byte_match_set(
    ByteMatchSetId='string'
)
type ByteMatchSetId

string

param ByteMatchSetId

[REQUIRED]

The ByteMatchSetId of the ByteMatchSet that you want to get. ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets.

rtype

dict

returns

Response Syntax

{
    'ByteMatchSet': {
        'ByteMatchSetId': 'string',
        'Name': 'string',
        'ByteMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TargetString': b'bytes',
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
            },
        ]
    }
}

Response Structure

  • (dict) --

    • ByteMatchSet (dict) --

      Information about the ByteMatchSet that you specified in the GetByteMatchSet request. For more information, see the following topics:

      • ByteMatchSet: Contains ByteMatchSetId , ByteMatchTuples , and Name

      • ByteMatchTuples : Contains an array of ByteMatchTuple objects. Each ByteMatchTuple object contains FieldToMatch, PositionalConstraint , TargetString , and TextTransformation

      • FieldToMatch: Contains Data and Type

      • ByteMatchSetId (string) --

        The ByteMatchSetId for a ByteMatchSet . You use ByteMatchSetId to get information about a ByteMatchSet (see GetByteMatchSet ), update a ByteMatchSet (see UpdateByteMatchSet ), insert a ByteMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a ByteMatchSet from AWS WAF (see DeleteByteMatchSet ).

        ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets.

      • Name (string) --

        A friendly name or description of the ByteMatchSet. You can't change Name after you create a ByteMatchSet .

      • ByteMatchTuples (list) --

        Specifies the bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.

        • (dict) --

          The bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings.

          • FieldToMatch (dict) --

            The part of a web request that you want AWS WAF to search, such as a specified header or a query string. For more information, see FieldToMatch.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TargetString (bytes) --

            The value that you want AWS WAF to search for. AWS WAF searches for the specified string in the part of web requests that you specified in FieldToMatch . The maximum length of the value is 50 bytes.

            Valid values depend on the values that you specified for FieldToMatch :

            • HEADER : The value that you want AWS WAF to search for in the request header that you specified in FieldToMatch, for example, the value of the User-Agent or Referer header.

            • METHOD : The HTTP method, which indicates the type of operation specified in the request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

            • QUERY_STRING : The value that you want AWS WAF to search for in the query string, which is the part of a URL that appears after a ? character.

            • URI : The value that you want AWS WAF to search for in the part of a URL that identifies a resource, for example, /images/daily-ad.jpg .

            • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

            • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

            • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but instead of inspecting a single parameter, AWS WAF inspects all parameters within the query string for the value or regex pattern that you specify in TargetString .

            If TargetString includes alphabetic characters A-Z and a-z, note that the value is case sensitive.

            If you're using the AWS WAF API

            Specify a base64-encoded version of the value. The maximum length of the value before you base64-encode it is 50 bytes.

            For example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you base64-encode BadBot using MIME base64 encoding and include the resulting value, QmFkQm90 , in the value of TargetString .

            If you're using the AWS CLI or one of the AWS SDKs

            The value that you want AWS WAF to search for. The SDK automatically base64 encodes the value.

          • TextTransformation (string) --

            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 TargetString before inspecting a request 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.

          • PositionalConstraint (string) --

            Within the portion of a web request that you want to search (for example, in the query string, if any), specify where you want AWS WAF to search. Valid values include the following:

            CONTAINS

            The specified part of the web request must include the value of TargetString , but the location doesn't matter.

            CONTAINS_WORD

            The specified part of the web request must include the value of TargetString , and TargetString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, TargetString must be a word, which means one of the following:

            • TargetString exactly matches the value of the specified part of the web request, such as the value of a header.

            • TargetString is at the beginning of the specified part of the web request and is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; .

            • TargetString is at the end of the specified part of the web request and is preceded by a character other than an alphanumeric character or underscore (_), for example, ;BadBot .

            • TargetString is in the middle of the specified part of the web request and is preceded and followed by characters other than alphanumeric characters or underscore (_), for example, -BadBot; .

            EXACTLY

            The value of the specified part of the web request must exactly match the value of TargetString .

            STARTS_WITH

            The value of TargetString must appear at the beginning of the specified part of the web request.

            ENDS_WITH

            The value of TargetString must appear at the end of the specified part of the web request.

GetRegexMatchSet (updated) Link ¶
Changes (response)
{'RegexMatchSet': {'RegexMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                  'SINGLE_QUERY_ARG'}}}}}

Returns the RegexMatchSet specified by RegexMatchSetId .

See also: AWS API Documentation

Request Syntax

client.get_regex_match_set(
    RegexMatchSetId='string'
)
type RegexMatchSetId

string

param RegexMatchSetId

[REQUIRED]

The RegexMatchSetId of the RegexMatchSet that you want to get. RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets.

rtype

dict

returns

Response Syntax

{
    'RegexMatchSet': {
        'RegexMatchSetId': 'string',
        'Name': 'string',
        'RegexMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'RegexPatternSetId': 'string'
            },
        ]
    }
}

Response Structure

  • (dict) --

    • RegexMatchSet (dict) --

      Information about the RegexMatchSet that you specified in the GetRegexMatchSet request. For more information, see RegexMatchTuple.

      • RegexMatchSetId (string) --

        The RegexMatchSetId for a RegexMatchSet . You use RegexMatchSetId to get information about a RegexMatchSet (see GetRegexMatchSet ), update a RegexMatchSet (see UpdateRegexMatchSet ), insert a RegexMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a RegexMatchSet from AWS WAF (see DeleteRegexMatchSet ).

        RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets.

      • Name (string) --

        A friendly name or description of the RegexMatchSet. You can't change Name after you create a RegexMatchSet .

      • RegexMatchTuples (list) --

        Contains an array of RegexMatchTuple objects. Each RegexMatchTuple object contains:

        • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

        • The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet.

        • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

        • (dict) --

          The regular expression pattern that you want AWS WAF to search for in web requests, the location in requests that you want AWS WAF to search, and other settings. Each RegexMatchTuple object contains:

          • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

          • The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet.

          • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for the RegexPatternSet .

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 RegexPatternSet before inspecting a request 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 commandline 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.

          • RegexPatternSetId (string) --

            The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet (see GetRegexPatternSet ), update a RegexPatternSet (see UpdateRegexPatternSet ), insert a RegexPatternSet into a RegexMatchSet or delete one from a RegexMatchSet (see UpdateRegexMatchSet ), and delete an RegexPatternSet from AWS WAF (see DeleteRegexPatternSet ).

            RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets.

GetSizeConstraintSet (updated) Link ¶
Changes (response)
{'SizeConstraintSet': {'SizeConstraints': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                     'SINGLE_QUERY_ARG'}}}}}

Returns the SizeConstraintSet specified by SizeConstraintSetId .

See also: AWS API Documentation

Request Syntax

client.get_size_constraint_set(
    SizeConstraintSetId='string'
)
type SizeConstraintSetId

string

param SizeConstraintSetId

[REQUIRED]

The SizeConstraintSetId of the SizeConstraintSet that you want to get. SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets.

rtype

dict

returns

Response Syntax

{
    'SizeConstraintSet': {
        'SizeConstraintSetId': 'string',
        'Name': 'string',
        'SizeConstraints': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
                'Size': 123
            },
        ]
    }
}

Response Structure

  • (dict) --

    • SizeConstraintSet (dict) --

      Information about the SizeConstraintSet that you specified in the GetSizeConstraintSet request. For more information, see the following topics:

      • SizeConstraintSet: Contains SizeConstraintSetId , SizeConstraints , and Name

      • SizeConstraints : Contains an array of SizeConstraint objects. Each SizeConstraint object contains FieldToMatch, TextTransformation , ComparisonOperator , and Size

      • FieldToMatch: Contains Data and Type

      • SizeConstraintSetId (string) --

        A unique identifier for a SizeConstraintSet . You use SizeConstraintSetId to get information about a SizeConstraintSet (see GetSizeConstraintSet ), update a SizeConstraintSet (see UpdateSizeConstraintSet ), insert a SizeConstraintSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SizeConstraintSet from AWS WAF (see DeleteSizeConstraintSet ).

        SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets.

      • Name (string) --

        The name, if any, of the SizeConstraintSet .

      • SizeConstraints (list) --

        Specifies the parts of web requests that you want to inspect the size of.

        • (dict) --

          Specifies a constraint on the size of a part of the web request. AWS WAF uses the Size , ComparisonOperator , and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for the size constraint.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 a request for a match.

            You can only specify a single type of TextTransformation.

            Note that if you choose BODY for the value of Type , you must choose NONE for TextTransformation because CloudFront forwards only the first 8192 bytes for inspection.

            NONE

            Specify NONE if you don't want to perform any text transformations.

            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.

          • ComparisonOperator (string) --

            The type of comparison you want AWS WAF to perform. AWS WAF uses this in combination with the provided Size and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

            EQ : Used to test if the Size is equal to the size of the FieldToMatch

            NE : Used to test if the Size is not equal to the size of the FieldToMatch

            LE : Used to test if the Size is less than or equal to the size of the FieldToMatch

            LT : Used to test if the Size is strictly less than the size of the FieldToMatch

            GE : Used to test if the Size is greater than or equal to the size of the FieldToMatch

            GT : Used to test if the Size is strictly greater than the size of the FieldToMatch

          • Size (integer) --

            The size in bytes that you want AWS WAF to compare against the size of the specified FieldToMatch . AWS WAF uses this in combination with ComparisonOperator and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

            Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).

            If you specify URI for the value of Type , the / in the URI counts as one character. For example, the URI /logo.jpg is nine characters long.

GetSqlInjectionMatchSet (updated) Link ¶
Changes (response)
{'SqlInjectionMatchSet': {'SqlInjectionMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                                'SINGLE_QUERY_ARG'}}}}}

Returns the SqlInjectionMatchSet that is specified by SqlInjectionMatchSetId .

See also: AWS API Documentation

Request Syntax

client.get_sql_injection_match_set(
    SqlInjectionMatchSetId='string'
)
type SqlInjectionMatchSetId

string

param SqlInjectionMatchSetId

[REQUIRED]

The SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to get. SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets.

rtype

dict

returns

Response Syntax

{
    'SqlInjectionMatchSet': {
        'SqlInjectionMatchSetId': 'string',
        'Name': 'string',
        'SqlInjectionMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
            },
        ]
    }
}

Response Structure

  • (dict) --

    The response to a GetSqlInjectionMatchSet request.

    • SqlInjectionMatchSet (dict) --

      Information about the SqlInjectionMatchSet that you specified in the GetSqlInjectionMatchSet request. For more information, see the following topics:

      • SqlInjectionMatchSet: Contains Name , SqlInjectionMatchSetId , and an array of SqlInjectionMatchTuple objects

      • SqlInjectionMatchTuple: Each SqlInjectionMatchTuple object contains FieldToMatch and TextTransformation

      • FieldToMatch: Contains Data and Type

      • SqlInjectionMatchSetId (string) --

        A unique identifier for a SqlInjectionMatchSet . You use SqlInjectionMatchSetId to get information about a SqlInjectionMatchSet (see GetSqlInjectionMatchSet ), update a SqlInjectionMatchSet (see UpdateSqlInjectionMatchSet ), insert a SqlInjectionMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete a SqlInjectionMatchSet from AWS WAF (see DeleteSqlInjectionMatchSet ).

        SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets.

      • Name (string) --

        The name, if any, of the SqlInjectionMatchSet .

      • SqlInjectionMatchTuples (list) --

        Specifies the parts of web requests that you want to inspect for snippets of malicious SQL code.

        • (dict) --

          Specifies the part of a web request that you want AWS WAF to inspect for snippets of malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for snippets of malicious SQL code.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 a request 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.

GetXssMatchSet (updated) Link ¶
Changes (response)
{'XssMatchSet': {'XssMatchTuples': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                              'SINGLE_QUERY_ARG'}}}}}

Returns the XssMatchSet that is specified by XssMatchSetId .

See also: AWS API Documentation

Request Syntax

client.get_xss_match_set(
    XssMatchSetId='string'
)
type XssMatchSetId

string

param XssMatchSetId

[REQUIRED]

The XssMatchSetId of the XssMatchSet that you want to get. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets.

rtype

dict

returns

Response Syntax

{
    'XssMatchSet': {
        'XssMatchSetId': 'string',
        'Name': 'string',
        'XssMatchTuples': [
            {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
            },
        ]
    }
}

Response Structure

  • (dict) --

    The response to a GetXssMatchSet request.

    • XssMatchSet (dict) --

      Information about the XssMatchSet that you specified in the GetXssMatchSet request. For more information, see the following topics:

      • XssMatchSet: Contains Name , XssMatchSetId , and an array of XssMatchTuple objects

      • XssMatchTuple: Each XssMatchTuple object contains FieldToMatch and TextTransformation

      • FieldToMatch: Contains Data and Type

      • XssMatchSetId (string) --

        A unique identifier for an XssMatchSet . You use XssMatchSetId to get information about an XssMatchSet (see GetXssMatchSet ), update an XssMatchSet (see UpdateXssMatchSet ), insert an XssMatchSet into a Rule or delete one from a Rule (see UpdateRule ), and delete an XssMatchSet from AWS WAF (see DeleteXssMatchSet ).

        XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets.

      • Name (string) --

        The name, if any, of the XssMatchSet .

      • XssMatchTuples (list) --

        Specifies the parts of web requests that you want to inspect for cross-site scripting attacks.

        • (dict) --

          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.

          • FieldToMatch (dict) --

            Specifies where in a web request to look for cross-site scripting attacks.

            • Type (string) --

              The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

              • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

              • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

              • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

              • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

              • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

              • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

              • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

            • Data (string) --

              When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

              When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

              If the value of Type is any other value, omit Data .

          • TextTransformation (string) --

            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 a request 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.

UpdateByteMatchSet (updated) Link ¶
Changes (request)
{'Updates': {'ByteMatchTuple': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                          'SINGLE_QUERY_ARG'}}}}}

Inserts or deletes ByteMatchTuple objects (filters) in a ByteMatchSet. For each ByteMatchTuple object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a ByteMatchSetUpdate object, you delete the existing object and add a new one.

  • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

  • The bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to look for. For more information, including how you specify the values for the AWS WAF API and the AWS CLI or SDKs, see TargetString in the ByteMatchTuple data type.

  • Where to look, such as at the beginning or the end of a query string.

  • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

For example, you can add a ByteMatchSetUpdate object that matches web requests in which User-Agent headers contain the string BadBot . You can then configure AWS WAF to block those requests.

To create and configure a ByteMatchSet , perform the following steps:

  • Create a ByteMatchSet. For more information, see CreateByteMatchSet.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateByteMatchSet request.

  • Submit an UpdateByteMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.update_byte_match_set(
    ByteMatchSetId='string',
    ChangeToken='string',
    Updates=[
        {
            'Action': 'INSERT'|'DELETE',
            'ByteMatchTuple': {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TargetString': b'bytes',
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'PositionalConstraint': 'EXACTLY'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS'|'CONTAINS_WORD'
            }
        },
    ]
)
type ByteMatchSetId

string

param ByteMatchSetId

[REQUIRED]

The ByteMatchSetId of the ByteMatchSet that you want to update. ByteMatchSetId is returned by CreateByteMatchSet and by ListByteMatchSets.

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

type Updates

list

param Updates

[REQUIRED]

An array of ByteMatchSetUpdate objects that you want to insert into or delete from a ByteMatchSet. For more information, see the applicable data types:

  • ByteMatchSetUpdate: Contains Action and ByteMatchTuple

  • ByteMatchTuple: Contains FieldToMatch , PositionalConstraint , TargetString , and TextTransformation

  • FieldToMatch: Contains Data and Type

  • (dict) --

    In an UpdateByteMatchSet request, ByteMatchSetUpdate specifies whether to insert or delete a ByteMatchTuple and includes the settings for the ByteMatchTuple .

    • Action (string) -- [REQUIRED]

      Specifies whether to insert or delete a ByteMatchTuple.

    • ByteMatchTuple (dict) -- [REQUIRED]

      Information about the part of a web request that you want AWS WAF to inspect and the value that you want AWS WAF to search for. If you specify DELETE for the value of Action , the ByteMatchTuple values must exactly match the values in the ByteMatchTuple that you want to delete from the ByteMatchSet .

      • FieldToMatch (dict) -- [REQUIRED]

        The part of a web request that you want AWS WAF to search, such as a specified header or a query string. For more information, see FieldToMatch.

        • Type (string) -- [REQUIRED]

          The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

          • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

          • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

          • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

          • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

          • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

          • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

          • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

        • Data (string) --

          When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

          When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

          If the value of Type is any other value, omit Data .

      • TargetString (bytes) -- [REQUIRED]

        The value that you want AWS WAF to search for. AWS WAF searches for the specified string in the part of web requests that you specified in FieldToMatch . The maximum length of the value is 50 bytes.

        Valid values depend on the values that you specified for FieldToMatch :

        • HEADER : The value that you want AWS WAF to search for in the request header that you specified in FieldToMatch, for example, the value of the User-Agent or Referer header.

        • METHOD : The HTTP method, which indicates the type of operation specified in the request. CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

        • QUERY_STRING : The value that you want AWS WAF to search for in the query string, which is the part of a URL that appears after a ? character.

        • URI : The value that you want AWS WAF to search for in the part of a URL that identifies a resource, for example, /images/daily-ad.jpg .

        • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

        • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

        • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but instead of inspecting a single parameter, AWS WAF inspects all parameters within the query string for the value or regex pattern that you specify in TargetString .

        If TargetString includes alphabetic characters A-Z and a-z, note that the value is case sensitive.

        If you're using the AWS WAF API

        Specify a base64-encoded version of the value. The maximum length of the value before you base64-encode it is 50 bytes.

        For example, suppose the value of Type is HEADER and the value of Data is User-Agent . If you want to search the User-Agent header for the value BadBot , you base64-encode BadBot using MIME base64 encoding and include the resulting value, QmFkQm90 , in the value of TargetString .

        If you're using the AWS CLI or one of the AWS SDKs

        The value that you want AWS WAF to search for. The SDK automatically base64 encodes the value.

      • TextTransformation (string) -- [REQUIRED]

        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 TargetString before inspecting a request 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.

      • PositionalConstraint (string) -- [REQUIRED]

        Within the portion of a web request that you want to search (for example, in the query string, if any), specify where you want AWS WAF to search. Valid values include the following:

        CONTAINS

        The specified part of the web request must include the value of TargetString , but the location doesn't matter.

        CONTAINS_WORD

        The specified part of the web request must include the value of TargetString , and TargetString must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, TargetString must be a word, which means one of the following:

        • TargetString exactly matches the value of the specified part of the web request, such as the value of a header.

        • TargetString is at the beginning of the specified part of the web request and is followed by a character other than an alphanumeric character or underscore (_), for example, BadBot; .

        • TargetString is at the end of the specified part of the web request and is preceded by a character other than an alphanumeric character or underscore (_), for example, ;BadBot .

        • TargetString is in the middle of the specified part of the web request and is preceded and followed by characters other than alphanumeric characters or underscore (_), for example, -BadBot; .

        EXACTLY

        The value of the specified part of the web request must exactly match the value of TargetString .

        STARTS_WITH

        The value of TargetString must appear at the beginning of the specified part of the web request.

        ENDS_WITH

        The value of TargetString must appear at the end of the specified part of the web request.

rtype

dict

returns

Response Syntax

{
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    • ChangeToken (string) --

      The ChangeToken that you used to submit the UpdateByteMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

UpdateRegexMatchSet (updated) Link ¶
Changes (request)
{'Updates': {'RegexMatchTuple': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                           'SINGLE_QUERY_ARG'}}}}}

Inserts or deletes RegexMatchTuple objects (filters) in a RegexMatchSet. For each RegexMatchSetUpdate object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a RegexMatchSetUpdate object, you delete the existing object and add a new one.

  • The part of a web request that you want AWS WAF to inspectupdate, such as a query string or the value of the User-Agent header.

  • The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet.

  • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

For example, you can create a RegexPatternSet that matches any requests with User-Agent headers that contain the string B[a@]dB[o0]t . You can then configure AWS WAF to reject those requests.

To create and configure a RegexMatchSet , perform the following steps:

  • Create a RegexMatchSet. For more information, see CreateRegexMatchSet.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateRegexMatchSet request.

  • Submit an UpdateRegexMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the identifier of the RegexPatternSet that contain the regular expression patters you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.update_regex_match_set(
    RegexMatchSetId='string',
    Updates=[
        {
            'Action': 'INSERT'|'DELETE',
            'RegexMatchTuple': {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'RegexPatternSetId': 'string'
            }
        },
    ],
    ChangeToken='string'
)
type RegexMatchSetId

string

param RegexMatchSetId

[REQUIRED]

The RegexMatchSetId of the RegexMatchSet that you want to update. RegexMatchSetId is returned by CreateRegexMatchSet and by ListRegexMatchSets.

type Updates

list

param Updates

[REQUIRED]

An array of RegexMatchSetUpdate objects that you want to insert into or delete from a RegexMatchSet. For more information, see RegexMatchTuple.

  • (dict) --

    In an UpdateRegexMatchSet request, RegexMatchSetUpdate specifies whether to insert or delete a RegexMatchTuple and includes the settings for the RegexMatchTuple .

    • Action (string) -- [REQUIRED]

      Specifies whether to insert or delete a RegexMatchTuple.

    • RegexMatchTuple (dict) -- [REQUIRED]

      Information about the part of a web request that you want AWS WAF to inspect and the identifier of the regular expression (regex) pattern that you want AWS WAF to search for. If you specify DELETE for the value of Action , the RegexMatchTuple values must exactly match the values in the RegexMatchTuple that you want to delete from the RegexMatchSet .

      • FieldToMatch (dict) -- [REQUIRED]

        Specifies where in a web request to look for the RegexPatternSet .

        • Type (string) -- [REQUIRED]

          The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

          • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

          • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

          • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

          • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

          • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

          • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

          • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

        • Data (string) --

          When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

          When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

          If the value of Type is any other value, omit Data .

      • TextTransformation (string) -- [REQUIRED]

        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 RegexPatternSet before inspecting a request 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 commandline 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.

      • RegexPatternSetId (string) -- [REQUIRED]

        The RegexPatternSetId for a RegexPatternSet . You use RegexPatternSetId to get information about a RegexPatternSet (see GetRegexPatternSet ), update a RegexPatternSet (see UpdateRegexPatternSet ), insert a RegexPatternSet into a RegexMatchSet or delete one from a RegexMatchSet (see UpdateRegexMatchSet ), and delete an RegexPatternSet from AWS WAF (see DeleteRegexPatternSet ).

        RegexPatternSetId is returned by CreateRegexPatternSet and by ListRegexPatternSets.

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

rtype

dict

returns

Response Syntax

{
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    • ChangeToken (string) --

      The ChangeToken that you used to submit the UpdateRegexMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

UpdateSizeConstraintSet (updated) Link ¶
Changes (request)
{'Updates': {'SizeConstraint': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                          'SINGLE_QUERY_ARG'}}}}}

Inserts or deletes SizeConstraint objects (filters) in a SizeConstraintSet. For each SizeConstraint object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a SizeConstraintSetUpdate object, you delete the existing object and add a new one.

  • The part of a web request that you want AWS WAF to evaluate, such as the length of a query string or the length of the User-Agent header.

  • Whether to perform any transformations on the request, such as converting it to lowercase, before checking its length. Note that transformations of the request body are not supported because the AWS resource forwards only the first 8192 bytes of your request to AWS WAF. You can only specify a single type of TextTransformation.

  • A ComparisonOperator used for evaluating the selected part of the request against the specified Size , such as equals, greater than, less than, and so on.

  • The length, in bytes, that you want AWS WAF to watch for in selected part of the request. The length is computed after applying the transformation.

For example, you can add a SizeConstraintSetUpdate object that matches web requests in which the length of the User-Agent header is greater than 100 bytes. You can then configure AWS WAF to block those requests.

To create and configure a SizeConstraintSet , perform the following steps:

  • Create a SizeConstraintSet. For more information, see CreateSizeConstraintSet.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateSizeConstraintSet request.

  • Submit an UpdateSizeConstraintSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.update_size_constraint_set(
    SizeConstraintSetId='string',
    ChangeToken='string',
    Updates=[
        {
            'Action': 'INSERT'|'DELETE',
            'SizeConstraint': {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE',
                'ComparisonOperator': 'EQ'|'NE'|'LE'|'LT'|'GE'|'GT',
                'Size': 123
            }
        },
    ]
)
type SizeConstraintSetId

string

param SizeConstraintSetId

[REQUIRED]

The SizeConstraintSetId of the SizeConstraintSet that you want to update. SizeConstraintSetId is returned by CreateSizeConstraintSet and by ListSizeConstraintSets.

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

type Updates

list

param Updates

[REQUIRED]

An array of SizeConstraintSetUpdate objects that you want to insert into or delete from a SizeConstraintSet. For more information, see the applicable data types:

  • SizeConstraintSetUpdate: Contains Action and SizeConstraint

  • SizeConstraint: Contains FieldToMatch , TextTransformation , ComparisonOperator , and Size

  • FieldToMatch: Contains Data and Type

  • (dict) --

    Specifies the part of a web request that you want to inspect the size of and indicates whether you want to add the specification to a SizeConstraintSet or delete it from a SizeConstraintSet .

    • Action (string) -- [REQUIRED]

      Specify INSERT to add a SizeConstraintSetUpdate to a SizeConstraintSet. Use DELETE to remove a SizeConstraintSetUpdate from a SizeConstraintSet .

    • SizeConstraint (dict) -- [REQUIRED]

      Specifies a constraint on the size of a part of the web request. AWS WAF uses the Size , ComparisonOperator , and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

      • FieldToMatch (dict) -- [REQUIRED]

        Specifies where in a web request to look for the size constraint.

        • Type (string) -- [REQUIRED]

          The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

          • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

          • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

          • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

          • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

          • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

          • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

          • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

        • Data (string) --

          When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

          When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

          If the value of Type is any other value, omit Data .

      • TextTransformation (string) -- [REQUIRED]

        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 a request for a match.

        You can only specify a single type of TextTransformation.

        Note that if you choose BODY for the value of Type , you must choose NONE for TextTransformation because CloudFront forwards only the first 8192 bytes for inspection.

        NONE

        Specify NONE if you don't want to perform any text transformations.

        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.

      • ComparisonOperator (string) -- [REQUIRED]

        The type of comparison you want AWS WAF to perform. AWS WAF uses this in combination with the provided Size and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

        EQ : Used to test if the Size is equal to the size of the FieldToMatch

        NE : Used to test if the Size is not equal to the size of the FieldToMatch

        LE : Used to test if the Size is less than or equal to the size of the FieldToMatch

        LT : Used to test if the Size is strictly less than the size of the FieldToMatch

        GE : Used to test if the Size is greater than or equal to the size of the FieldToMatch

        GT : Used to test if the Size is strictly greater than the size of the FieldToMatch

      • Size (integer) -- [REQUIRED]

        The size in bytes that you want AWS WAF to compare against the size of the specified FieldToMatch . AWS WAF uses this in combination with ComparisonOperator and FieldToMatch to build an expression in the form of " Size ComparisonOperator size in bytes of FieldToMatch ". If that expression is true, the SizeConstraint is considered to match.

        Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).

        If you specify URI for the value of Type , the / in the URI counts as one character. For example, the URI /logo.jpg is nine characters long.

rtype

dict

returns

Response Syntax

{
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    • ChangeToken (string) --

      The ChangeToken that you used to submit the UpdateSizeConstraintSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

UpdateSqlInjectionMatchSet (updated) Link ¶
Changes (request)
{'Updates': {'SqlInjectionMatchTuple': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                                  'SINGLE_QUERY_ARG'}}}}}

Inserts or deletes SqlInjectionMatchTuple objects (filters) in a SqlInjectionMatchSet. For each SqlInjectionMatchTuple object, you specify the following values:

  • Action : Whether to insert the object into or delete the object from the array. To change a SqlInjectionMatchTuple , you delete the existing object and add a new one.

  • FieldToMatch : The part of web requests that you want AWS WAF to inspect and, if you want AWS WAF to inspect a header or custom query parameter, the name of the header or parameter.

  • TextTransformation : Which text transformation, if any, to perform on the web request before inspecting the request for snippets of malicious SQL code. You can only specify a single type of TextTransformation.

You use SqlInjectionMatchSet objects to specify which CloudFront requests you want to allow, block, or count. For example, if you're receiving requests that contain snippets of SQL code in the query string and you want to block the requests, you can create a SqlInjectionMatchSet with the applicable settings, and then configure AWS WAF to block the requests.

To create and configure a SqlInjectionMatchSet , perform the following steps:

  • Submit a CreateSqlInjectionMatchSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateIPSet request.

  • Submit an UpdateSqlInjectionMatchSet request to specify the parts of web requests that you want AWS WAF to inspect for snippets of SQL code.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.update_sql_injection_match_set(
    SqlInjectionMatchSetId='string',
    ChangeToken='string',
    Updates=[
        {
            'Action': 'INSERT'|'DELETE',
            'SqlInjectionMatchTuple': {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
            }
        },
    ]
)
type SqlInjectionMatchSetId

string

param SqlInjectionMatchSetId

[REQUIRED]

The SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to update. SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by ListSqlInjectionMatchSets.

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

type Updates

list

param Updates

[REQUIRED]

An array of SqlInjectionMatchSetUpdate objects that you want to insert into or delete from a SqlInjectionMatchSet. For more information, see the applicable data types:

  • SqlInjectionMatchSetUpdate: Contains Action and SqlInjectionMatchTuple

  • SqlInjectionMatchTuple: Contains FieldToMatch and TextTransformation

  • FieldToMatch: Contains Data and Type

  • (dict) --

    Specifies the part of a web request that you want to inspect for snippets of malicious SQL code and indicates whether you want to add the specification to a SqlInjectionMatchSet or delete it from a SqlInjectionMatchSet .

    • Action (string) -- [REQUIRED]

      Specify INSERT to add a SqlInjectionMatchSetUpdate to a SqlInjectionMatchSet. Use DELETE to remove a SqlInjectionMatchSetUpdate from a SqlInjectionMatchSet .

    • SqlInjectionMatchTuple (dict) -- [REQUIRED]

      Specifies the part of a web request that you want AWS WAF to inspect for snippets of malicious SQL code and, if you want AWS WAF to inspect a header, the name of the header.

      • FieldToMatch (dict) -- [REQUIRED]

        Specifies where in a web request to look for snippets of malicious SQL code.

        • Type (string) -- [REQUIRED]

          The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

          • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

          • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

          • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

          • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

          • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

          • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

          • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

        • Data (string) --

          When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

          When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

          If the value of Type is any other value, omit Data .

      • TextTransformation (string) -- [REQUIRED]

        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 a request 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.

rtype

dict

returns

Response Syntax

{
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    The response to an UpdateSqlInjectionMatchSets request.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the UpdateSqlInjectionMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

UpdateXssMatchSet (updated) Link ¶
Changes (request)
{'Updates': {'XssMatchTuple': {'FieldToMatch': {'Type': {'ALL_QUERY_ARGS',
                                                         'SINGLE_QUERY_ARG'}}}}}

Inserts or deletes XssMatchTuple objects (filters) in an XssMatchSet. For each XssMatchTuple object, you specify the following values:

  • Action : Whether to insert the object into or delete the object from the array. To change a XssMatchTuple , you delete the existing object and add a new one.

  • FieldToMatch : The part of web requests that you want AWS WAF to inspect and, if you want AWS WAF to inspect a header or custom query parameter, the name of the header or parameter.

  • TextTransformation : Which text transformation, if any, to perform on the web request before inspecting the request for cross-site scripting attacks. You can only specify a single type of TextTransformation.

You use XssMatchSet objects to specify which CloudFront requests you want to allow, block, or count. For example, if you're receiving requests that contain cross-site scripting attacks in the request body and you want to block the requests, you can create an XssMatchSet with the applicable settings, and then configure AWS WAF to block the requests.

To create and configure an XssMatchSet , perform the following steps:

  • Submit a CreateXssMatchSet request.

  • Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateIPSet request.

  • Submit an UpdateXssMatchSet request to specify the parts of web requests that you want AWS WAF to inspect for cross-site scripting attacks.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

See also: AWS API Documentation

Request Syntax

client.update_xss_match_set(
    XssMatchSetId='string',
    ChangeToken='string',
    Updates=[
        {
            'Action': 'INSERT'|'DELETE',
            'XssMatchTuple': {
                'FieldToMatch': {
                    'Type': 'URI'|'QUERY_STRING'|'HEADER'|'METHOD'|'BODY'|'SINGLE_QUERY_ARG'|'ALL_QUERY_ARGS',
                    'Data': 'string'
                },
                'TextTransformation': 'NONE'|'COMPRESS_WHITE_SPACE'|'HTML_ENTITY_DECODE'|'LOWERCASE'|'CMD_LINE'|'URL_DECODE'
            }
        },
    ]
)
type XssMatchSetId

string

param XssMatchSetId

[REQUIRED]

The XssMatchSetId of the XssMatchSet that you want to update. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets.

type ChangeToken

string

param ChangeToken

[REQUIRED]

The value returned by the most recent call to GetChangeToken.

type Updates

list

param Updates

[REQUIRED]

An array of XssMatchSetUpdate objects that you want to insert into or delete from a XssMatchSet. For more information, see the applicable data types:

  • XssMatchSetUpdate: Contains Action and XssMatchTuple

  • XssMatchTuple: Contains FieldToMatch and TextTransformation

  • FieldToMatch: Contains Data and Type

  • (dict) --

    Specifies the part of a web request that you want to inspect for cross-site scripting attacks and indicates whether you want to add the specification to an XssMatchSet or delete it from an XssMatchSet .

    • Action (string) -- [REQUIRED]

      Specify INSERT to add a XssMatchSetUpdate to an XssMatchSet. Use DELETE to remove a XssMatchSetUpdate from an XssMatchSet .

    • XssMatchTuple (dict) -- [REQUIRED]

      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.

      • FieldToMatch (dict) -- [REQUIRED]

        Specifies where in a web request to look for cross-site scripting attacks.

        • Type (string) -- [REQUIRED]

          The part of the web request that you want AWS WAF to search for a specified string. Parts of a request that you can search include the following:

          • HEADER : A specified request header, for example, the value of the User-Agent or Referer header. If you choose HEADER for the type, specify the name of the header in Data .

          • METHOD : The HTTP method, which indicated the type of operation that the request is asking the origin to perform. Amazon CloudFront supports the following methods: DELETE , GET , HEAD , OPTIONS , PATCH , POST , and PUT .

          • QUERY_STRING : A query string, which is the part of a URL that appears after a ? character, if any.

          • URI : The part of a web request that identifies a resource, for example, /images/daily-ad.jpg .

          • BODY : The part of a request that contains any additional data that you want to send to your web server as the HTTP request body, such as data from a form. The request body immediately follows the request headers. Note that only the first 8192 bytes of the request body are forwarded to AWS WAF for inspection. To allow or block requests based on the length of the body, you can create a size constraint set. For more information, see CreateSizeConstraintSet.

          • SINGLE_QUERY_ARG : The parameter in the query string that you will inspect, such as UserName or SalesRegion . The maximum length for SINGLE_QUERY_ARG is 30 characters.

          • ALL_QUERY_ARGS : Similar to SINGLE_QUERY_ARG , but rather than inspecting a single parameter, AWS WAF will inspect all parameters within the query for the value or regex pattern that you specify in TargetString .

        • Data (string) --

          When the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer . The name of the header is not case sensitive.

          When the value of Type is SINGLE_QUERY_ARG , enter the name of the parameter that you want AWS WAF to search, for example, UserName or SalesRegion . The parameter name is not case sensitive.

          If the value of Type is any other value, omit Data .

      • TextTransformation (string) -- [REQUIRED]

        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 a request 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.

rtype

dict

returns

Response Syntax

{
    'ChangeToken': 'string'
}

Response Structure

  • (dict) --

    The response to an UpdateXssMatchSets request.

    • ChangeToken (string) --

      The ChangeToken that you used to submit the UpdateXssMatchSet request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.