Exception settings
Look up the fields of a WAF exception, its fifteen match zones, the Tuning screen, and the API and CLI that manage it.
An exception is an entry on a WAF rule set that exempts part of a request from one internal rule, or from all of them. It takes effect on every Firewall with a rule whose Set WAF behavior applies that rule set. Azion Console calls the same entity an allowed rule, and the API and the Azion CLI call it an exception.
Fields
Azion Console lists the exceptions of a rule set on its Allowed Rules tab, where Allowed Rule opens the Create Allowed Rule drawer, and the description of each field names its Console label. An exception carries six fields a request can set. Three more are set by the platform and are returned in a response, never sent.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id |
integer | Read-only | — | The identifier every later call uses |
rule_id |
integer | No | 0 |
The internal rule the exception applies to. 0 means all rules. It is fixed at create, and a later change returns 26005. The Console renders it as the Rule ID dropdown |
name |
string, 1 to 255 characters | Yes | — | Free text saying what the exception is for. Two exceptions can carry the same name. The Console renders it as the Description field |
path |
string, up to 255 characters, nullable | No | null |
Restricts the exception to one request path, which matched only exactly in tests. An exception with no path applied on every path tested. The Console renders it as the Path field |
conditions |
array of objects, at least 1 entry | Yes | — | The parts of the request the exception covers, listed in Conditions. The Console renders each entry as a Condition field |
operator |
string | No | contains |
How the strings in the exception are compared: contains or regex. The Console renders it as the Active switch of the Regex section, which sends regex when on |
active |
boolean | No | true |
Whether the exception is in force. An inactive exception stays on the rule set and stops exempting anything. The Console renders it as the Active switch of the Status section |
last_editor |
string | Read-only | — | The email of the account that last changed the exception |
last_modified |
date-time | Read-only | — | When the exception last changed |
The smallest exception the API accepts carries a name and one condition. It then applies to all rules, on every path, with contains, and is active.
rule_id takes one identifier from the internal rules, and 0 stands for all of them. For the list of identifiers and what each rule detects, refer to WAF Rule Sets. The same identifiers name the rows on the Tuning screen, and the Console shows each rule’s own description beside its identifier.
last_editor and last_modified are returned by the API and the CLI. The Console form does not show them.
Conditions
A condition names one match zone, and where the zone is specific, the string that zone applies to. The shape of a condition is fixed by its match value, and there are three.
| Shape | Keys | Match zones that take it |
|---|---|---|
| Generic | match |
The nine zones whose name carries no specific |
| Specific on a name | match and name |
specific_body_form_field_name, specific_http_header_name, specific_query_string_name |
| Specific on a value | match and value |
specific_body_form_field_value, specific_http_header_value, specific_query_string_value |
A condition’s name or value holds between 1 and 255 characters. A specific_* condition sent with neither returns 400 with 10059 Required Field, and one sent with an empty string returns 400 with 10018 Blank Field. A character such as [ or é returns 400 with 26000 Invalid Zone Input, and [ does so under regex as well as under contains.
An exception can carry several conditions, and every entry is kept, within two limits. At most one condition uses a specific_* match zone, and a second one returns 26004. No two conditions target the same part of the request, such as any_query_string_name with any_query_string_value, and such a pair returns 26003. A generic and a specific_* zone on the same part are accepted together, such as any_query_string_value with specific_query_string_name.
Operator
operator decides how the strings in the exception are compared, and it governs two places at once: the exception’s path and the condition’s name or value.
Under the default contains, neither string is read as a pattern. In tests, the exception’s path matched the request path only exactly. An exception on /hdr did not cover /hdrx or /other/hdr, one on /x6 did not cover /x6/data, and one on / did not cover other paths. For what each condition cleared at runtime, refer to Match zones.
Under regex, both are regular expressions, and each is validated separately. A malformed path returns 400 with 26008 Invalid Regex Value and a source pointer of /data/path; a malformed condition name returns the same code with a pointer of /data/conditions/0/name. There is no way to make one a regular expression and the other a literal. regex widens both together, so an exception that needs a pattern in its condition also needs one in its path.
The Console renders the choice as the Active switch of the Regex section, which treats the condition fields as regular expressions in all match zones. The switch sends regex when on and contains when off.
Match zones
A match zone is the part of a request a condition compares. The API takes it as conditions[].match. The Azion Console labels the field Condition, not match zone, and seeds it with Any HTTP Header Value.
There are fifteen, listed below in the order the Console offers them. An option beginning Specific reveals an extra Name or Value field, and which of the two appears is fixed by the option.
| Console option | API value | Condition shape | What it compares |
|---|---|---|---|
| Any HTTP Header Value | any_http_header_value |
Generic | The value of every request header, such as Mozilla/5.0 or application/json |
| Any HTTP Header Name | any_http_header_name |
Generic | The name of every request header, such as User-Agent or Authorization |
| Specific HTTP Header Value | specific_http_header_value |
Specific on a value | The value in the condition. In tests, a header name in value cleared the match on that header only |
| Specific HTTP Header Name | specific_http_header_name |
Specific on a name | The name in the condition, such as cookie. In tests, it did not clear a match on that header |
| Any Query String Value | any_query_string_value |
Generic | The value of every query string parameter. In ?id=123&user=admin, 123 and admin |
| Any Query String Name | any_query_string_name |
Generic | The name of every query string parameter. In ?id=123&user=admin, id and user |
| Specific Query String Value | specific_query_string_value |
Specific on a value | The value in the condition. In tests, a parameter name in value cleared the match on that parameter only |
| Specific Query String Name | specific_query_string_name |
Specific on a name | The name in the condition, such as token. In tests, it did not clear a match on that parameter |
| Body Form Field Value | body_form_field_value |
Generic | The value of every form field in the request body |
| Body Form Field Name | body_form_field_name |
Generic | The name of every form field in the request body |
| Specific Body Form Field Value | specific_body_form_field_value |
Specific on a value | The value in the condition, against the value of every form field in the body |
| Specific Body Form Field Name | specific_body_form_field_name |
Specific on a name | The name in the condition, such as api_key, against the name of a form field in the body |
| Any URL | any_url |
Generic | The request URL |
| Raw Body | raw_body |
Generic | The uninterpreted request body, such as a JSON or an XML payload |
| File Extension | file_extension |
Generic | The file extension in the request, such as .php, .exe or .sh |
A value outside this set returns 400 with 10039 Invalid Choice and a source pointer naming the condition, such as /data/conditions/0/match.
specific_http_header_value with a header name in value cleared one header in tests. Its two keys are match and value. An exception of {"match": "specific_http_header_value", "value": "cookie"} with rule 1005 cleared a match on a Cookie header whose value did not contain cookie. A pipe character in a query string parameter of the same request was still refused.
specific_http_header_name stores a header name, but at runtime it did not clear a match on that header. The API stores the string exactly as it is sent, so cookie, Cookie, and HTTP_COOKIE are all accepted and all read back unchanged. In a test, an exception with name cookie or HTTP_COOKIE and the rule ID of a match on the Cookie header left that match in place for 24 minutes. An exception with any_http_header_value and the same rule_id cleared it.
In the same way, specific_query_string_name did not clear a match on its parameter in 24 minutes, while any_query_string_value with the rule_id cleared every parameter. specific_query_string_value with the parameter name filter in value cleared the match on filter only, and another parameter was still refused. The same zone with the parameter’s value in value did not clear the match.
Tuning
Tuning is a tab on a rule set that lists the requests each internal rule matched over a chosen window, one row per rule ID, and turns selected records into exceptions in bulk. It reads only the requests of a Workload whose deployment sets a Firewall with a Set WAF behavior that applies the rule set. A query needs a Workload, or a domain on an account that still uses Domains, and the other filters narrow it.
| Filter | What it narrows |
|---|---|
| Workload or Domain | The requests read. Required |
| Time Range | The window the requests are read over: Last 1 hour, Last 3 hours, Last 6 hours, Last 12 hours, Last day, Last 2 days, or Last 3 days, the longest window available |
| Network Lists | The requests whose source address a Network List holds |
| IP Address | The requests from one or more source addresses. The Console refuses it together with an IP/CIDR Network List filter |
| Country | The country the request came from. The Console refuses it together with a Countries Network List filter |
| Path | Only in More Details, which lists the occurrences behind one rule ID and also takes the other filters |
Each row carries the columns Rule ID, Hits, Paths, IPs, Countries, Top 10 IP Addresses, and Top 10 Countries. Allow Rules writes the selected records to the rule set as exceptions, one for each possible attack on each URI, and Create from Tuning on the Allowed Rules tab opens this screen.
For the procedure, refer to Tune a WAF rule set. For why tuning is repeated rather than done once, refer to Scoring and modes.
API
Every operation is authenticated and sits under https://api.azion.com/v4/workspace/wafs/{waf_id}/exceptions. A request carries a token from Personal Tokens in the Authorization header under the Token scheme, and a request with a body also carries Content-Type: application/json. The API manages exceptions independently of the Console, so one can be created, changed, or removed from a script.
| Operation | Method and path |
|---|---|
| Create an exception | POST /wafs/{waf_id}/exceptions |
| List exceptions | GET /wafs/{waf_id}/exceptions |
| Retrieve an exception | GET /wafs/{waf_id}/exceptions/{exception_id} |
| Replace an exception | PUT /wafs/{waf_id}/exceptions/{exception_id} |
| Update part of an exception | PATCH /wafs/{waf_id}/exceptions/{exception_id} |
| Delete an exception | DELETE /wafs/{waf_id}/exceptions/{exception_id} |
A create, a replace, a partial update, and a delete answer 202. A read answers 200.
The operations above are ordinary API calls, so exception management belongs in a delivery pipeline like any other configuration change. The evidence an exception is written from comes from a different surface: Tuning is an Azion Console screen, and the API does not expose it. A script reads that evidence from Real-Time Events, where wafMatch names the internal rules a request matched and wafScore reports the score each threat family reached. It then creates an exception for each false positive those records confirm.
The Azion CLI is the other surface, and on Azion CLI 4.26.2 its --conditions flag, azion update waf-exceptions, and azion delete waf-exceptions fail. A script therefore creates exceptions with --file and changes or removes them through the API.
Create an exception
The response carries 202, and not 201:
The state of pending says the exception was accepted, and the id in data is the handle every later call uses. last_editor carries the email of the account that last changed the exception, and the value above is a placeholder.
The same call with the body below stores a specific_query_string_name condition on the parameter named q. The response carries 202, a new id of 123457, and the condition echoed unchanged.
The body below stores a specific_query_string_value condition instead. It answers 202 with an id of 123458.
List exceptions
The response carries 200 and the collection envelope below, with one exception per entry under results, each in the shape the create response carries.
| Field | What it carries |
|---|---|
count |
Exceptions the rule set holds |
total_pages |
Pages the result divides into, at the current page_size |
page |
The page this response carries |
page_size |
Exceptions per page. Defaults to 10 |
next |
The URL of the following page, or null |
previous |
The URL of the preceding page, or null |
results |
One exception per entry, carrying the fields listed in Fields |
The endpoint accepts created_at__gte, created_at__lte, description, fields, id, last_editor, last_modified__gte, last_modified__lte, ordering, page, page_size, path, and search as query parameters. page_size runs from 1 to 100 and defaults to 10. A value above 100 returns 400 with 10097 Invalid Page Size.
Retrieve, update, and delete an exception
GET /wafs/{waf_id}/exceptions/{exception_id} answers 200 and returns the exception under data, with no state key.
PUT /wafs/{waf_id}/exceptions/{exception_id} replaces an exception and takes the same body as a create. It answers 202 with a state of pending. The conditions array is replaced rather than merged, so a replace sends every condition the exception is to keep. A replace that leaves out active sets it back to true.
rule_id cannot change after create. A replace or a partial update that carries another rule_id returns 26005, and so does a replace that omits rule_id on an exception whose rule_id is not 0.
PATCH /wafs/{waf_id}/exceptions/{exception_id} takes only the fields sent and answers 202. A body of {"active": false} deactivates an exception and leaves the rest of it as it was. A conditions array in a partial update replaces the whole array.
DELETE /wafs/{waf_id}/exceptions/{exception_id} answers 202 with a body of {"state": "pending"}.
CLI
The Azion CLI manages exceptions under the waf-exceptions noun. The flags below are the ones Azion CLI 4.26.2 carries, without the global flags every command takes.
| Command | What it does |
|---|---|
azion create waf-exceptions |
Creates an exception on a rule set |
azion list waf-exceptions |
Lists the exceptions a rule set holds |
azion describe waf-exceptions |
Returns one exception |
azion update waf-exceptions |
Changes an exception |
azion delete waf-exceptions |
Removes an exception |
azion create waf-exceptions and azion update waf-exceptions share their flags, except that --exception-id belongs to the update.
| Flag | What it sets |
|---|---|
--waf-id |
The rule set the exception belongs to |
--name |
The exception name |
--rule-id |
The internal rule the exception applies to |
--path |
The path the exception is restricted to |
--operator |
regex or contains |
--active |
true or false. Defaults to true |
--conditions |
The conditions, in JSON. Refer to the caution below before using it |
--file |
A JSON file carrying the body, or - to read the body from standard input |
--exception-id |
The exception to change. azion update waf-exceptions only |
azion list waf-exceptions takes --waf-id, --details, --filter, --order-by, --page with a default of 1, and --page-size with a default of 50. azion describe waf-exceptions and azion delete waf-exceptions each take --waf-id and --exception-id.
Write the body to a file:
Then create the exception from it:
azion describe waf-exceptions returns one exception, with the keys sorted by the CLI:
Errors
A rejected request answers 400 with an errors array, except 10004, which answers 404, and 10009, which answers 415. Each entry carries a code, a title, a detail, the status, and a source pointer naming the field the rejection is about. For a condition the pointer indexes into the array, so /data/conditions/0/name names the first condition:
| Code | Title | Message | Cause | Fix |
|---|---|---|---|---|
10004 |
Not Found | Not found. |
A waf_id or an exception_id that does not exist. |
Check every segment of the path. |
10009 |
Unsupported Media Type | Unsupported media type "<media-type>" in request. |
A write sent with a Content-Type other than application/json. |
Send Content-Type: application/json. |
10018 |
Blank Field | This field may not be blank. |
name, or a condition’s name or value, is an empty string. |
Send 1 to 255 characters. |
10039 |
Invalid Choice | "<value>" is not a valid choice. |
A value outside an enum: rule_id, operator, or a condition’s match. |
Send one of the values listed in Fields and Match zones. The source pointer names the field. |
10046 |
Max Length | Ensure this field has no more than 255 characters. |
name, path, or a condition’s name or value is longer than 255 characters. |
Shorten the value. |
10049 |
Min Length List Field | Ensure this field has at least 1 elements. |
An empty conditions array, which is what azion create waf-exceptions --conditions always sends. |
Send at least one condition, through the API or azion create waf-exceptions --file. |
10059 |
Required Field | This field is required. |
A required field is absent: name, conditions, or the name or value of a specific_* condition. |
Add the field the source pointer names. |
10097 |
Invalid Page Size | Page size must be between 0 and 100. |
A page_size of 0 or above 100 on a list request. |
Ask for 1 to 100. |
26000 |
Invalid Zone Input | Enter a valid string with letters, numbers, symbols and space. |
A condition’s name or value holds a character the API refuses, such as [ or é. |
Remove the character. |
26003 |
Conflicting Match Conditions. | More than one match condition on the same target. |
Two conditions target the same part of the request, such as two specific_query_string_name entries. meta.zone_value names the part. |
Keep one condition per part, or split them across exceptions. |
26004 |
Only One ‘specific’ Match Condition Is Allowed Per WAF Exception. | We support only one 'specific' match condition is allowed per WAF Exception. |
Two specific_* conditions in one exception. |
Create one exception for each specific_* condition. |
26005 |
Immutable WAF Exception Field | You can't change it after creating the WAF Exception. |
A replace or a partial update changes rule_id, including a replace that omits it on an exception whose rule_id is not 0. |
Send the current rule_id, or create another exception for the other rule. |
26008 |
Invalid Regex Value | The value '<value>' for this field is not valid regex value. |
operator is regex and the exception’s path, or a condition’s name or value, is not a valid pattern. |
Fix the pattern the source pointer names. The entry’s meta.regex_value repeats the value that failed. |
A rule_id of 0 is not an error. It is the legal value meaning all rules, and it answers 202 like any other.
The Azion CLI prints the API message inside its own error. For 10049, the last line reads: