Skip to content

Commit d4d4c53

Browse files
AWS WAF now lets you inspect fragments of request URIs. You can specify the scope of the URI to inspect and narrow the set of URI fragments.
1 parent 89f35a6 commit d4d4c53

File tree

9 files changed

+338
-2
lines changed

9 files changed

+338
-2
lines changed

generator/ServiceModels/wafv2/wafv2-2019-07-29.api.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,8 @@
19861986
"Cookies":{"shape":"Cookies"},
19871987
"HeaderOrder":{"shape":"HeaderOrder"},
19881988
"JA3Fingerprint":{"shape":"JA3Fingerprint"},
1989-
"JA4Fingerprint":{"shape":"JA4Fingerprint"}
1989+
"JA4Fingerprint":{"shape":"JA4Fingerprint"},
1990+
"UriFragment":{"shape":"UriFragment"}
19901991
}
19911992
},
19921993
"FieldToMatchData":{
@@ -4255,6 +4256,12 @@
42554256
"NextLockToken":{"shape":"LockToken"}
42564257
}
42574258
},
4259+
"UriFragment":{
4260+
"type":"structure",
4261+
"members":{
4262+
"FallbackBehavior":{"shape":"FallbackBehavior"}
4263+
}
4264+
},
42584265
"UriPath":{
42594266
"type":"structure",
42604267
"members":{

generator/ServiceModels/wafv2/wafv2-2019-07-29.docs.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,8 @@
831831
"JA3Fingerprint$FallbackBehavior": "<p>The match status to assign to the web request if the request doesn't have a JA3 fingerprint. </p> <p>You can specify the following fallback behaviors:</p> <ul> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul>",
832832
"JA4Fingerprint$FallbackBehavior": "<p>The match status to assign to the web request if the request doesn't have a JA4 fingerprint. </p> <p>You can specify the following fallback behaviors:</p> <ul> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul>",
833833
"RateLimitJA3Fingerprint$FallbackBehavior": "<p>The match status to assign to the web request if there is insufficient TSL Client Hello information to compute the JA3 fingerprint.</p> <p>You can specify the following fallback behaviors:</p> <ul> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul>",
834-
"RateLimitJA4Fingerprint$FallbackBehavior": "<p>The match status to assign to the web request if there is insufficient TSL Client Hello information to compute the JA4 fingerprint.</p> <p>You can specify the following fallback behaviors:</p> <ul> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul>"
834+
"RateLimitJA4Fingerprint$FallbackBehavior": "<p>The match status to assign to the web request if there is insufficient TSL Client Hello information to compute the JA4 fingerprint.</p> <p>You can specify the following fallback behaviors:</p> <ul> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul>",
835+
"UriFragment$FallbackBehavior": "<p>What WAF should do if it fails to completely parse the JSON body. The options are the following:</p> <ul> <li> <p> <code>EVALUATE_AS_STRING</code> - Inspect the body as plain text. WAF applies the text transformations and inspection criteria that you defined for the JSON inspection to the body text string.</p> </li> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul> <p>If you don't provide this setting, WAF parses and evaluates the content only up to the first parsing failure that it encounters. </p> <p>Example JSON: <code>{ \"UriFragment\": { \"FallbackBehavior\": \"MATCH\"} }</code> </p> <note> <p>WAF parsing doesn't fully validate the input JSON string, so parsing can succeed even for invalid JSON. When parsing succeeds, WAF doesn't apply the fallback behavior. For more information, see <a href=\"https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-fields-list.html#waf-rule-statement-request-component-json-body\">JSON body</a> in the <i>WAF Developer Guide</i>.</p> </note>"
835836
}
836837
},
837838
"FieldIdentifier": {
@@ -2709,6 +2710,12 @@
27092710
"refs": {
27102711
}
27112712
},
2713+
"UriFragment": {
2714+
"base": "<p>Inspect fragments of the request URI. You can specify the parts of the URI fragment to inspect and you can narrow the set of URI fragments to inspect by including or excluding specific keys. </p> <p>This is used to indicate the web request component to inspect, in the <a>FieldToMatch</a> specification. </p> <p>Example JSON: <code>\"UriFragment\": { \"MatchPattern\": { \"All\": {} }, \"MatchScope\": \"KEY\", \"OversizeHandling\": \"MATCH\" }</code> </p>",
2715+
"refs": {
2716+
"FieldToMatch$UriFragment": "<p>Inspect fragments of the request URI. You must configure scope and pattern matching filters in the <code>UriFragment</code> object, to define the fragment of a URI that WAF inspects. </p> <p>Only the first 8 KB (8192 bytes) of a request's URI fragments and only the first 200 URI fragments are forwarded to WAF for inspection by the underlying host service. You must configure how to handle any oversize URI fragment content in the <code>UriFragment</code> object. WAF applies the pattern matching filters to the cookies that it receives from the underlying host service. </p>"
2717+
}
2718+
},
27122719
"UriPath": {
27132720
"base": "<p>Inspect the path component of the URI of the web request. This is the part of the web request that identifies a resource. For example, <code>/images/daily-ad.jpg</code>.</p> <p>This is used in the <a>FieldToMatch</a> specification for some web request component types. </p> <p>JSON specification: <code>\"UriPath\": {}</code> </p>",
27142721
"refs": {

generator/ServiceModels/wafv2/wafv2-2019-07-29.normal.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,6 +2556,10 @@
25562556
"JA4Fingerprint":{
25572557
"shape":"JA4Fingerprint",
25582558
"documentation":"<p>Available for use with Amazon CloudFront distributions and Application Load Balancers. Match against the request's JA4 fingerprint. The JA4 fingerprint is a 36-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. 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.</p> <note> <p>You can use this choice only with a string match <code>ByteMatchStatement</code> with the <code>PositionalConstraint</code> set to <code>EXACTLY</code>. </p> </note> <p>You can obtain the JA4 fingerprint for client requests from the web ACL logs. If WAF is able to calculate the fingerprint, it includes it in the logs. For information about the logging fields, see <a href=\"https://docs.aws.amazon.com/waf/latest/developerguide/logging-fields.html\">Log fields</a> in the <i>WAF Developer Guide</i>. </p> <p>Provide the JA4 fingerprint string from the logs in your string match statement specification, to match with any future requests that have the same TLS configuration.</p>"
2559+
},
2560+
"UriFragment":{
2561+
"shape":"UriFragment",
2562+
"documentation":"<p>Inspect fragments of the request URI. You must configure scope and pattern matching filters in the <code>UriFragment</code> object, to define the fragment of a URI that WAF inspects. </p> <p>Only the first 8 KB (8192 bytes) of a request's URI fragments and only the first 200 URI fragments are forwarded to WAF for inspection by the underlying host service. You must configure how to handle any oversize URI fragment content in the <code>UriFragment</code> object. WAF applies the pattern matching filters to the cookies that it receives from the underlying host service. </p>"
25592563
}
25602564
},
25612565
"documentation":"<p>Specifies a web request component to be used in a rule match statement or in a logging configuration. </p> <ul> <li> <p>In a rule statement, this is the part of the web request that you want WAF to inspect. Include the single <code>FieldToMatch</code> type that you want to inspect, with additional specifications as needed, according to the type. You specify a single request component in <code>FieldToMatch</code> 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.</p> <p>Example JSON for a <code>QueryString</code> field to match: </p> <p> <code> \"FieldToMatch\": { \"QueryString\": {} }</code> </p> <p>Example JSON for a <code>Method</code> field to match specification:</p> <p> <code> \"FieldToMatch\": { \"Method\": { \"Name\": \"DELETE\" } }</code> </p> </li> <li> <p>In a logging configuration, this is used in the <code>RedactedFields</code> property to specify a field to redact from the logging records. For this use case, note the following: </p> <ul> <li> <p>Even though all <code>FieldToMatch</code> settings are available, the only valid settings for field redaction are <code>UriPath</code>, <code>QueryString</code>, <code>SingleHeader</code>, and <code>Method</code>.</p> </li> <li> <p>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. </p> </li> <li> <p>If you have request sampling enabled, the redacted fields configuration for logging has no impact on sampling. You can only exclude fields from request sampling by disabling sampling in the web ACL visibility configuration or by configuring data protection for the web ACL.</p> </li> </ul> </li> </ul>"
@@ -6304,6 +6308,16 @@
63046308
}
63056309
}
63066310
},
6311+
"UriFragment":{
6312+
"type":"structure",
6313+
"members":{
6314+
"FallbackBehavior":{
6315+
"shape":"FallbackBehavior",
6316+
"documentation":"<p>What WAF should do if it fails to completely parse the JSON body. The options are the following:</p> <ul> <li> <p> <code>EVALUATE_AS_STRING</code> - Inspect the body as plain text. WAF applies the text transformations and inspection criteria that you defined for the JSON inspection to the body text string.</p> </li> <li> <p> <code>MATCH</code> - Treat the web request as matching the rule statement. WAF applies the rule action to the request.</p> </li> <li> <p> <code>NO_MATCH</code> - Treat the web request as not matching the rule statement.</p> </li> </ul> <p>If you don't provide this setting, WAF parses and evaluates the content only up to the first parsing failure that it encounters. </p> <p>Example JSON: <code>{ \"UriFragment\": { \"FallbackBehavior\": \"MATCH\"} }</code> </p> <note> <p>WAF parsing doesn't fully validate the input JSON string, so parsing can succeed even for invalid JSON. When parsing succeeds, WAF doesn't apply the fallback behavior. For more information, see <a href=\"https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-fields-list.html#waf-rule-statement-request-component-json-body\">JSON body</a> in the <i>WAF Developer Guide</i>.</p> </note>"
6317+
}
6318+
},
6319+
"documentation":"<p>Inspect fragments of the request URI. You can specify the parts of the URI fragment to inspect and you can narrow the set of URI fragments to inspect by including or excluding specific keys. </p> <p>This is used to indicate the web request component to inspect, in the <a>FieldToMatch</a> specification. </p> <p>Example JSON: <code>\"UriFragment\": { \"MatchPattern\": { \"All\": {} }, \"MatchScope\": \"KEY\", \"OversizeHandling\": \"MATCH\" }</code> </p>"
6320+
},
63076321
"UriPath":{
63086322
"type":"structure",
63096323
"members":{

sdk/src/Services/WAFV2/Generated/Model/FieldToMatch.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public partial class FieldToMatch
9898
private QueryString _queryString;
9999
private SingleHeader _singleHeader;
100100
private SingleQueryArgument _singleQueryArgument;
101+
private UriFragment _uriFragment;
101102
private UriPath _uriPath;
102103

103104
/// <summary>
@@ -451,6 +452,34 @@ internal bool IsSetSingleQueryArgument()
451452
return this._singleQueryArgument != null;
452453
}
453454

455+
/// <summary>
456+
/// Gets and sets the property UriFragment.
457+
/// <para>
458+
/// Inspect fragments of the request URI. You must configure scope and pattern matching
459+
/// filters in the <c>UriFragment</c> object, to define the fragment of a URI that WAF
460+
/// inspects.
461+
/// </para>
462+
///
463+
/// <para>
464+
/// Only the first 8 KB (8192 bytes) of a request's URI fragments and only the first 200
465+
/// URI fragments are forwarded to WAF for inspection by the underlying host service.
466+
/// You must configure how to handle any oversize URI fragment content in the <c>UriFragment</c>
467+
/// object. WAF applies the pattern matching filters to the cookies that it receives from
468+
/// the underlying host service.
469+
/// </para>
470+
/// </summary>
471+
public UriFragment UriFragment
472+
{
473+
get { return this._uriFragment; }
474+
set { this._uriFragment = value; }
475+
}
476+
477+
// Check to see if UriFragment property is set
478+
internal bool IsSetUriFragment()
479+
{
480+
return this._uriFragment != null;
481+
}
482+
454483
/// <summary>
455484
/// Gets and sets the property UriPath.
456485
/// <para>

sdk/src/Services/WAFV2/Generated/Model/Internal/MarshallTransformations/FieldToMatchMarshaller.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ public void Marshall(FieldToMatch requestObject, JsonMarshallerContext context)
180180
context.Writer.WriteObjectEnd();
181181
}
182182

183+
if(requestObject.IsSetUriFragment())
184+
{
185+
context.Writer.WritePropertyName("UriFragment");
186+
context.Writer.WriteObjectStart();
187+
188+
var marshaller = UriFragmentMarshaller.Instance;
189+
marshaller.Marshall(requestObject.UriFragment, context);
190+
191+
context.Writer.WriteObjectEnd();
192+
}
193+
183194
if(requestObject.IsSetUriPath())
184195
{
185196
context.Writer.WritePropertyName("UriPath");

sdk/src/Services/WAFV2/Generated/Model/Internal/MarshallTransformations/FieldToMatchUnmarshaller.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ public FieldToMatch Unmarshall(JsonUnmarshallerContext context)
138138
unmarshalledObject.SingleQueryArgument = unmarshaller.Unmarshall(context);
139139
continue;
140140
}
141+
if (context.TestExpression("UriFragment", targetDepth))
142+
{
143+
var unmarshaller = UriFragmentUnmarshaller.Instance;
144+
unmarshalledObject.UriFragment = unmarshaller.Unmarshall(context);
145+
continue;
146+
}
141147
if (context.TestExpression("UriPath", targetDepth))
142148
{
143149
var unmarshaller = UriPathUnmarshaller.Instance;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the wafv2-2019-07-29.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Text;
24+
using System.Xml.Serialization;
25+
26+
using Amazon.WAFV2.Model;
27+
using Amazon.Runtime;
28+
using Amazon.Runtime.Internal;
29+
using Amazon.Runtime.Internal.Transform;
30+
using Amazon.Runtime.Internal.Util;
31+
using ThirdParty.Json.LitJson;
32+
33+
#pragma warning disable CS0612,CS0618
34+
namespace Amazon.WAFV2.Model.Internal.MarshallTransformations
35+
{
36+
/// <summary>
37+
/// UriFragment Marshaller
38+
/// </summary>
39+
public class UriFragmentMarshaller : IRequestMarshaller<UriFragment, JsonMarshallerContext>
40+
{
41+
/// <summary>
42+
/// Unmarshaller the response from the service to the response class.
43+
/// </summary>
44+
/// <param name="requestObject"></param>
45+
/// <param name="context"></param>
46+
/// <returns></returns>
47+
public void Marshall(UriFragment requestObject, JsonMarshallerContext context)
48+
{
49+
if(requestObject == null)
50+
return;
51+
if(requestObject.IsSetFallbackBehavior())
52+
{
53+
context.Writer.WritePropertyName("FallbackBehavior");
54+
context.Writer.Write(requestObject.FallbackBehavior);
55+
}
56+
57+
}
58+
59+
/// <summary>
60+
/// Singleton Marshaller.
61+
/// </summary>
62+
public readonly static UriFragmentMarshaller Instance = new UriFragmentMarshaller();
63+
64+
}
65+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the wafv2-2019-07-29.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Net;
24+
using System.Text;
25+
using System.Xml.Serialization;
26+
27+
using Amazon.WAFV2.Model;
28+
using Amazon.Runtime;
29+
using Amazon.Runtime.Internal;
30+
using Amazon.Runtime.Internal.Transform;
31+
using Amazon.Runtime.Internal.Util;
32+
using ThirdParty.Json.LitJson;
33+
34+
#pragma warning disable CS0612,CS0618
35+
namespace Amazon.WAFV2.Model.Internal.MarshallTransformations
36+
{
37+
/// <summary>
38+
/// Response Unmarshaller for UriFragment Object
39+
/// </summary>
40+
public class UriFragmentUnmarshaller : IUnmarshaller<UriFragment, XmlUnmarshallerContext>, IUnmarshaller<UriFragment, JsonUnmarshallerContext>
41+
{
42+
/// <summary>
43+
/// Unmarshaller the response from the service to the response class.
44+
/// </summary>
45+
/// <param name="context"></param>
46+
/// <returns></returns>
47+
UriFragment IUnmarshaller<UriFragment, XmlUnmarshallerContext>.Unmarshall(XmlUnmarshallerContext context)
48+
{
49+
throw new NotImplementedException();
50+
}
51+
52+
/// <summary>
53+
/// Unmarshaller the response from the service to the response class.
54+
/// </summary>
55+
/// <param name="context"></param>
56+
/// <returns>The unmarshalled object</returns>
57+
public UriFragment Unmarshall(JsonUnmarshallerContext context)
58+
{
59+
UriFragment unmarshalledObject = new UriFragment();
60+
if (context.IsEmptyResponse)
61+
return null;
62+
context.Read();
63+
if (context.CurrentTokenType == JsonToken.Null)
64+
return null;
65+
66+
int targetDepth = context.CurrentDepth;
67+
while (context.ReadAtDepth(targetDepth))
68+
{
69+
if (context.TestExpression("FallbackBehavior", targetDepth))
70+
{
71+
var unmarshaller = StringUnmarshaller.Instance;
72+
unmarshalledObject.FallbackBehavior = unmarshaller.Unmarshall(context);
73+
continue;
74+
}
75+
}
76+
return unmarshalledObject;
77+
}
78+
79+
80+
private static UriFragmentUnmarshaller _instance = new UriFragmentUnmarshaller();
81+
82+
/// <summary>
83+
/// Gets the singleton.
84+
/// </summary>
85+
public static UriFragmentUnmarshaller Instance
86+
{
87+
get
88+
{
89+
return _instance;
90+
}
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)