Before deploying a new rule, it’s vital to test it. This is to ensure you don’t accidentally block valid requests.
So far you have used Block and Allow when specifying what action to take on a request. There is a third action, Count. Count allows you to measure the number of requests that would meet the rule conditions.
Count is a non-terminating action. When a request matches a rule with the Count action, the web ACL will continue processing the remaining rules.
You have developed a new rule for your WAF. Before you can deploy it, you must first test it. This is to reduce the risk of unintentionally introducing rules that block genuine requests.
The rule below blocks requests with the query parameter username.
{
"Name": "count-von-count",
"Priority": 0,
"Action": {
"Count": {}
},
"VisibilityConfig": {
"SampledRequestsEnabled": true,
"CloudWatchMetricsEnabled": true,
"MetricName": "count-von-count"
},
"Statement": {
"SizeConstraintStatement": {
"FieldToMatch": {
"SingleQueryArgument": {
"Name": "username"
}
},
"ComparisonOperator": "GT",
"Size": "0",
"TextTransformations": [
{
"Type": "NONE",
"Priority": 0
}
]
}
}
}
curl "<Your Juice Shop URL>?username=admin"
3. Go to CloudWatch Metrics.
Before deploying a new rule, it’s vital to test it. This is to ensure you don’t accidentally block valid requests.