Your business has developed an API that allows partners to retrieve a product list, with a maximum limit of 100 products per request. To enhance security, a WAF protection layer needs to be added. Your task is to configure the protection to allow only valid JSON requests and ensure that the numrecords value is within the range of 1 to 100.
Valid JSON example for this API:
{ "numrecords":"25" }
Only requests with valid JSON syntax and a numrecords value between 1 and 100 will be accepted. The API is available at the path /api/listproducts.php. Requests that fail validation must be rejected with an HTTP 400 response code.
First, create a regex pattern to validate the value of numrecords (1-100):
^0*(?:[1-9][0-9]?|100)$
Then, create a WAF rule consisting of two statements:
The procedure below is longer and more complex than the previous sections. Please pay close attention to the steps outlined below.
Create a regex pattern set that matches numbers 1-100:
Navigate to the Regex pattern sets section in WAF.
Select Create regex pattern set.
Regex pattern set name: number-1-to-100
Regular expressions: ^0(?:[1-9][0-9]?|100)$*
Click Create regex pattern

In the Web ACL, navigate to the Rules tab.
Select Add Rule.
Select Add my own rules and rule groups.




Verify JSON element matches regex statement:


2. On the Rules tab, verify that the new custom rule has been added successfully and listed.

