interface FieldToMatchProperty
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.WAFv2.CfnWebACL.FieldToMatchProperty |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awswafv2#CfnWebACL_FieldToMatchProperty |
Java | software.amazon.awscdk.services.wafv2.CfnWebACL.FieldToMatchProperty |
Python | aws_cdk.aws_wafv2.CfnWebACL.FieldToMatchProperty |
TypeScript | aws-cdk-lib » aws_wafv2 » CfnWebACL » FieldToMatchProperty |
Specifies a web request component to be used in a rule match statement or in a logging configuration.
- In a rule statement, this is the part of the web request that you want AWS WAF to inspect. Include the single
FieldToMatch
type that you want to inspect, with additional specifications as needed, according to the type. You specify a single request component inFieldToMatch
for each rule statement that requires it. To inspect more than one component of the web request, create a separate rule statement for each component.
Example JSON for a QueryString
field to match:
"FieldToMatch": { "QueryString": {} }
Example JSON for a Method
field to match specification:
"FieldToMatch": { "Method": { "Name": "DELETE" } }
In a logging configuration, this is used in the
RedactedFields
property to specify a field to redact from the logging records. For this use case, note the following:Even though all
FieldToMatch
settings are available, the only valid settings for field redaction areUriPath
,QueryString
,SingleHeader
, andMethod
.In this documentation, the descriptions of the individual fields talk about specifying the web request component to inspect, but for field redaction, you are specifying the component type to redact from the logs.
If you have request sampling enabled, the redacted fields configuration for logging has no impact on sampling. The only way to exclude fields from request sampling is by disabling sampling in the web ACL visibility configuration.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_wafv2 as wafv2 } from 'aws-cdk-lib';
declare const all: any;
declare const allQueryArguments: any;
declare const method: any;
declare const queryString: any;
declare const singleHeader: any;
declare const singleQueryArgument: any;
declare const uriPath: any;
const fieldToMatchProperty: wafv2.CfnWebACL.FieldToMatchProperty = {
allQueryArguments: allQueryArguments,
body: {
oversizeHandling: 'oversizeHandling',
},
cookies: {
matchPattern: {
all: all,
excludedCookies: ['excludedCookies'],
includedCookies: ['includedCookies'],
},
matchScope: 'matchScope',
oversizeHandling: 'oversizeHandling',
},
headers: {
matchPattern: {
all: all,
excludedHeaders: ['excludedHeaders'],
includedHeaders: ['includedHeaders'],
},
matchScope: 'matchScope',
oversizeHandling: 'oversizeHandling',
},
ja3Fingerprint: {
fallbackBehavior: 'fallbackBehavior',
},
jsonBody: {
matchPattern: {
all: all,
includedPaths: ['includedPaths'],
},
matchScope: 'matchScope',
// the properties below are optional
invalidFallbackBehavior: 'invalidFallbackBehavior',
oversizeHandling: 'oversizeHandling',
},
method: method,
queryString: queryString,
singleHeader: singleHeader,
singleQueryArgument: singleQueryArgument,
uriPath: uriPath,
};
Properties
Name | Type | Description |
---|---|---|
all | any | Inspect all query arguments. |
body? | IResolvable | Body | Inspect the request body as plain text. |
cookies? | IResolvable | Cookies | Inspect the request cookies. |
headers? | IResolvable | Headers | Inspect the request headers. |
ja3 | IResolvable | JA3 | Available for use with Amazon CloudFront distributions and Application Load Balancers. |
json | IResolvable | Json | Inspect the request body as JSON. |
method? | any | Inspect the HTTP method. |
query | any | Inspect the query string. |
single | any | Inspect a single header. |
single | any | Inspect a single query argument. |
uri | any | Inspect the request URI path. |
allQueryArguments?
Type:
any
(optional)
Inspect all query arguments.
body?
Type:
IResolvable
|
Body
(optional)
Inspect the request body as plain text.
The request body immediately follows the request headers. This is 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.
AWS WAF does not support inspecting the entire contents of the web request body if the body exceeds the limit for the resource type. When a web request body is larger than the limit, the underlying host service only forwards the contents that are within the limit to AWS WAF for inspection.
- For Application Load Balancer and AWS AppSync , the limit is fixed at 8 KB (8,192 bytes).
- For CloudFront, API Gateway, Amazon Cognito, App Runner, and Verified Access, the default limit is 16 KB (16,384 bytes), and you can increase the limit for each resource type in the web ACL
AssociationConfig
, for additional processing fees.
For information about how to handle oversized request bodies, see the Body
object configuration.
cookies?
Type:
IResolvable
|
Cookies
(optional)
Inspect the request cookies.
You must configure scope and pattern matching filters in the Cookies
object, to define the set of cookies and the parts of the cookies that AWS WAF inspects.
Only the first 8 KB (8192 bytes) of a request's cookies and only the first 200 cookies are forwarded to AWS WAF for inspection by the underlying host service. You must configure how to handle any oversize cookie content in the Cookies
object. AWS WAF applies the pattern matching filters to the cookies that it receives from the underlying host service.
headers?
Type:
IResolvable
|
Headers
(optional)
Inspect the request headers.
You must configure scope and pattern matching filters in the Headers
object, to define the set of headers to and the parts of the headers that AWS WAF inspects.
Only the first 8 KB (8192 bytes) of a request's headers and only the first 200 headers are forwarded to AWS WAF for inspection by the underlying host service. You must configure how to handle any oversize header content in the Headers
object. AWS WAF applies the pattern matching filters to the headers that it receives from the underlying host service.
ja3Fingerprint?
Type:
IResolvable
|
JA3
(optional)
Available for use with Amazon CloudFront distributions and Application Load Balancers.
Match against the request's JA3 fingerprint. The JA3 fingerprint is a 32-character hash derived from the TLS Client Hello of an incoming request. This fingerprint serves as a unique identifier for the client's TLS configuration. AWS WAF calculates and logs this fingerprint for each request that has enough TLS Client Hello information for the calculation. Almost all web requests include this information.
You can use this choice only with a string match
ByteMatchStatement
with thePositionalConstraint
set toEXACTLY
.
You can obtain the JA3 fingerprint for client requests from the web ACL logs. If AWS WAF is able to calculate the fingerprint, it includes it in the logs. For information about the logging fields, see Log fields in the AWS WAF Developer Guide .
Provide the JA3 fingerprint string from the logs in your string match statement specification, to match with any future requests that have the same TLS configuration.
jsonBody?
Type:
IResolvable
|
Json
(optional)
Inspect the request body as JSON.
The request body immediately follows the request headers. This is 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.
AWS WAF does not support inspecting the entire contents of the web request body if the body exceeds the limit for the resource type. When a web request body is larger than the limit, the underlying host service only forwards the contents that are within the limit to AWS WAF for inspection.
- For Application Load Balancer and AWS AppSync , the limit is fixed at 8 KB (8,192 bytes).
- For CloudFront, API Gateway, Amazon Cognito, App Runner, and Verified Access, the default limit is 16 KB (16,384 bytes), and you can increase the limit for each resource type in the web ACL
AssociationConfig
, for additional processing fees.
For information about how to handle oversized request bodies, see the JsonBody
object configuration.
method?
Type:
any
(optional)
Inspect the HTTP method.
The method indicates the type of operation that the request is asking the origin to perform.
queryString?
Type:
any
(optional)
Inspect the query string.
This is the part of a URL that appears after a ?
character, if any.
singleHeader?
Type:
any
(optional)
Inspect a single header.
Provide the name of the header to inspect, for example, User-Agent
or Referer
. This setting isn't case sensitive.
Example JSON: "SingleHeader": { "Name": "haystack" }
Alternately, you can filter and inspect all headers with the Headers
FieldToMatch
setting.
singleQueryArgument?
Type:
any
(optional)
Inspect a single query argument.
Provide the name of the query argument to inspect, such as UserName or SalesRegion . The name can be up to 30 characters long and isn't case sensitive.
Example JSON: "SingleQueryArgument": { "Name": "myArgument" }
uriPath?
Type:
any
(optional)
Inspect the request URI path.
This is the part of the web request that identifies a resource, for example, /images/daily-ad.jpg
.