Skip to content
Smarter by Design.Simpler for Business

waf rule-parts ​

The waf rule-parts command manages the inspection parts of a WAF rule. Every part targets a region of the request (the path, the query string, the headers, the body) and a key in that region, and determines the restrictions to be applied to that key and to its value.

Command Summary ​

TR7 WEB-CLI · waf rule-parts
# Tab after the command
admin@TR7LBWAF01> waf rule-parts
add delete list show update
 
admin@TR7LBWAF01> waf rule-parts list poolId <vservice> hostGroupId <group> ruleId <rule>
admin@TR7LBWAF01> waf rule-parts add poolId <vservice> hostGroupId <group> ruleId <rule> loc query …
admin@TR7LBWAF01> waf rule-parts update poolId <vservice> hostGroupId <group> ruleId <rule> id <id> …
admin@TR7LBWAF01> waf rule-parts delete poolId <vservice> hostGroupId <group> ruleId <rule> <id>
admin@TR7LBWAF01>  

Required Fields ​

In the add command the CLI asks for the required fields in the following order, one by one; it does not show the next one before one is written. The fields are written with the field name and its value together. The fields specific to the region open only after the fourth field, loc.

OrderFieldStatusValue
1poolIdRequiredThe vService record the part is bound to
2hostGroupIdRequiredThe host group record the part is bound to
3ruleIdRequiredThe rule the part belongs to; the rules are listed with the path they match
4locRequiredpath · query · header · json · xml · form · raw. It cannot be changed after it is created

In the update command, in the fourth place, instead of loc, id is asked for; the list, show and delete commands ask for the first three fields.

In the show and delete commands the identifier of the part is written without the field name after the first three fields. The parts are listed in the selection list in the region: key form, and the ones without a key as region: (all keys).

The Target Key ​

FieldWhat it doesWhat is written after it
--argDetermines to which key in the region the inspection will be appliedThe key name. When it is left empty, the inspection is applied to all the keys in the region. It cannot be changed after it is created

The Field Families According to the Regions ​

Every region opens its own field families. The table below shows which family is present in which regions; then the fields of every region are written one by one.

Field familyIn which regions
The total size restriction (Size)path · raw · query · header
The depth restriction (Depth)path · json · xml
The key restrictions (KeyLength, KeyCount, AllowedArgs)query · header · json · xml · form
The required keys (MustArgs)query · header · form
The content blocking (BlockAll, BlockInvalid)json · xml · form
The allowed MIME types (AllowedMimeTypes)form · raw

The size, depth, key length and key count restrictions all consist of the same three fields: the operator (.op), the value (.val) and the end of the range (.val2).

If the operator is not none, the value is required

The restriction in the schema requires, when the operator takes a value other than none, that the .val field be a number, and while the operator is -, additionally that the .val2 field be a number too.

loc path — the request path ​

FieldWhat it doesWhat is written after it
--pathSize.opSelects how the total size of the region will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–1024)
--pathSize.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--pathSize.val2Determines the end of the rangeA number; it is used only while the operator is -
--pathDepth.opSelects how the depth will be comparednone no restriction · <= · = · >= · - range (the default is <= 8)
--pathDepth.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--pathDepth.val2Determines the end of the rangeA number; it is used only while the operator is -

loc query — the query string ​

FieldWhat it doesWhat is written after it
--querySize.opSelects how the total size of the region will be comparednone no restriction · <= · = · >= · - range (the default is <= 8192)
--querySize.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--querySize.val2Determines the end of the rangeA number; it is used only while the operator is -
--queryKeyLength.opSelects how the length of the key name will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–128)
--queryKeyLength.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--queryKeyLength.val2Determines the end of the rangeA number; it is used only while the operator is -
--queryKeyCount.opSelects how the number of keys will be comparednone no restriction · <= · = · >= · - range (the default is <= 16)
--queryKeyCount.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--queryKeyCount.val2Determines the end of the rangeA number; it is used only while the operator is -
--queryAllowedArgs.NDetermines which keys will be allowed in the regionThe key name; every key with its own index. An empty list means no restriction
--queryMustArgs.NDetermines the keys that are required to be present in the regionThe key name; every key with its own index

loc header — the HTTP headers ​

FieldWhat it doesWhat is written after it
--headerSize.opSelects how the total size of the region will be comparednone no restriction · <= · = · >= · - range (the default is <= 4096)
--headerSize.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--headerSize.val2Determines the end of the rangeA number; it is used only while the operator is -
--headerKeyLength.opSelects how the length of the key name will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–128)
--headerKeyLength.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--headerKeyLength.val2Determines the end of the rangeA number; it is used only while the operator is -
--headerKeyCount.opSelects how the number of keys will be comparednone no restriction · <= · = · >= · - range (the default is <= 32)
--headerKeyCount.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--headerKeyCount.val2Determines the end of the rangeA number; it is used only while the operator is -
--headerAllowedArgs.NDetermines which keys will be allowed in the regionThe key name; every key with its own index. An empty list means no restriction
--headerMustArgs.NDetermines the keys that are required to be present in the regionThe key name; every key with its own index

loc json — the JSON body ​

FieldWhat it doesWhat is written after it
--jsonDepth.opSelects how the depth will be comparednone no restriction · <= · = · >= · - range (the default is <= 8)
--jsonDepth.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--jsonDepth.val2Determines the end of the rangeA number; it is used only while the operator is -
--jsonKeyLength.opSelects how the length of the key name will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–32)
--jsonKeyLength.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--jsonKeyLength.val2Determines the end of the rangeA number; it is used only while the operator is -
--jsonKeyCount.opSelects how the number of keys will be comparednone no restriction · <= · = · >= · - range (the default is <= 1024)
--jsonKeyCount.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--jsonKeyCount.val2Determines the end of the rangeA number; it is used only while the operator is -
--jsonAllowedArgs.NDetermines which keys will be allowed in the regionThe key name; every key with its own index. An empty list means no restriction
--jsonBlockAllTurns on all the content in the region being blockedtrue (the default) · false
--jsonBlockInvalidTurns on the invalid content in the region being blockedtrue (the default) · false

loc xml — the XML body ​

FieldWhat it doesWhat is written after it
--xmlDepth.opSelects how the depth will be comparednone no restriction · <= · = · >= · - range (the default is <= 32)
--xmlDepth.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--xmlDepth.val2Determines the end of the rangeA number; it is used only while the operator is -
--xmlKeyLength.opSelects how the length of the key name will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–64)
--xmlKeyLength.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--xmlKeyLength.val2Determines the end of the rangeA number; it is used only while the operator is -
--xmlKeyCount.opSelects how the number of keys will be comparednone no restriction · <= · = · >= · - range (the default is <= 1024)
--xmlKeyCount.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--xmlKeyCount.val2Determines the end of the rangeA number; it is used only while the operator is -
--xmlAllowedArgs.NDetermines which keys will be allowed in the regionThe key name; every key with its own index. An empty list means no restriction
--xmlBlockAllTurns on all the content in the region being blockedtrue (the default) · false
--xmlBlockInvalidTurns on the invalid content in the region being blockedtrue (the default) · false

loc form — the form body ​

FieldWhat it doesWhat is written after it
--formKeyLength.opSelects how the length of the key name will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–64)
--formKeyLength.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--formKeyLength.val2Determines the end of the rangeA number; it is used only while the operator is -
--formKeyCount.opSelects how the number of keys will be comparednone no restriction · <= · = · >= · - range (the default is <= 32)
--formKeyCount.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--formKeyCount.val2Determines the end of the rangeA number; it is used only while the operator is -
--formAllowedArgs.NDetermines which keys will be allowed in the regionThe key name; every key with its own index. An empty list means no restriction
--formMustArgs.NDetermines the keys that are required to be present in the regionThe key name; every key with its own index
--formBlockAllTurns on all the content in the region being blockedtrue (the default) · false
--formBlockInvalidTurns on the invalid content in the region being blockedtrue (the default) · false
--formAllowedMimeTypes.NDetermines which MIME types will be allowed in the regionThe MIME type; every type with its own index. An empty list means no restriction
--formFileOwaspTurns on the OWASP inspection being applied to the uploaded filestrue (the default) · false

loc raw — the raw body ​

FieldWhat it doesWhat is written after it
--rawSize.opSelects how the total size of the region will be comparednone no restriction · <= · = · >= · - range (the default is -, 1–16384)
--rawSize.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--rawSize.val2Determines the end of the rangeA number; it is used only while the operator is -
--rawAllowedMimeTypes.NDetermines which MIME types will be allowed in the regionThe MIME type; every type with its own index. An empty list means no restriction
--rawBlockUnparsedTurns on the raw body that cannot be parsed being blockedtrue (the default) · false
--rawBlockUnexpectedErrorTurns on the blocking on an unexpected parsing errortrue · false (the default is false)

The Fields Common to Every Region ​

The fields below are present in every part, independently of the loc value.

FieldWhat it doesWhat is written after it
--valueLength.opSelects how the length of the value of the key will be comparednone no restriction · <= · = · >= · - range (the default is -, 0–1024)
--valueLength.valDetermines the value to be comparedA number; while the operator is -, the beginning of the range
--valueLength.val2Determines the end of the rangeA number; it is used only while the operator is -
--argOwaspTurns on the OWASP inspections being applied to this parttrue (the default) · false
--argOwaspExclusions.NDetermines the OWASP rule keys that will not be applied in this partThe rule key; every key with its own index, the same key cannot be written twice
--argLogTurns on the value being written into the log at the blockingtrue (the default) · false
--argRegex.inputDetermines the regular expression the value has to matchA regular expression in the Hyperscan dialect. An empty input means no restriction
--argMultipleDetermines at most how many times the same key can be repeatedAn integer between 0 and 1000000

Examples ​

TR7 WEB-CLI · inspection parts
# let the value of a single key in the query string be a number and at most 8 characters
admin@TR7LBWAF01> waf rule-parts add poolId <vservice> hostGroupId <group> ruleId <rule> \
loc query --arg id \
--valueLength.op "<=" --valueLength.val 8 --argRegex.input "^[0-9]+$"
 
# across the region: at most 10 keys in the query, only three names allowed
admin@TR7LBWAF01> waf rule-parts add poolId <vservice> hostGroupId <group> ruleId <rule> \
loc query --queryKeyCount.op "<=" --queryKeyCount.val 10 \
--queryAllowedArgs.0 id --queryAllowedArgs.1 page --queryAllowedArgs.2 sort
 
# depth and invalid content inspection in the JSON body
admin@TR7LBWAF01> waf rule-parts add poolId <vservice> hostGroupId <group> ruleId <rule> \
loc json --jsonDepth.op "<=" --jsonDepth.val 6 --jsonBlockInvalid true
 
# the allowed MIME types in the form body
admin@TR7LBWAF01> waf rule-parts update poolId <vservice> hostGroupId <group> ruleId <rule> id <id> \
--formAllowedMimeTypes.0 image/png --formAllowedMimeTypes.1 image/jpeg
admin@TR7LBWAF01>  

Things to Know ​

  • A part belongs to a rule. In every command it is stated with poolId, hostGroupId and ruleId on the parts of which rule it is worked; the rules are in the waf fw-rules command.
  • The region and the key cannot be changed afterwards. The loc and --arg fields are marked as fixed in the schema; for another region or key a new part is created.
  • If the key is left empty, it becomes an inspection across the region. When --arg is not given, the inspection is applied to all the keys in the region.
  • The region determines the fields. The loc value determines which fields will be listed; the CLI asks for it after the poolId, hostGroupId and ruleId fields and the fields specific to the region open only after that.
  • The required fields do not take --. poolId, hostGroupId, ruleId and loc are written with the field name and its value side by side; the optional fields are in the --field value form. The detail is on the API Commands page.
  • The comparison operators require quotes. The values such as <=, >= and - are written inside double quotes so that they are not counted as a redirection by the shell.
  • An empty list means no restriction. When the allowed key and allowed MIME type lists are left empty, no restriction is applied in that region.
  • The records carry only the fields of their own region. According to the explanation in the schema, a part does not store the fields outside the region in which it was created.