Skip to content

Access rules, rate limits and exceptions ​

These commands read and replace the rule lists of an application (access rules, rate limits, exceptions, virtual patches and positive-model rules), and manage suggested rate limits.

waap rules get ​

Prints one of the application's rule lists as YAML, in order, with the version it was read from.

sh
waap rules get -app NAME -list LIST [-json]

LIST is one of:

  • access: access rules. The first match decides.
  • rate_limits
  • exceptions
  • virtual_patches
  • positive_rules: the positive model's learned and manual rules.

waap rules set ​

Replaces the list with the records in FILE, in order. The list is a YAML or JSON list; - reads standard input. [] removes the list.

sh
waap rules set -app NAME -list LIST -f FILE [-m WHY] [-dry-run]
FlagWhat it doesDefault
-app NAMEApplication whose list changes.
-list LISTList to replace: access, rate_limits, exceptions, virtual_patches or positive_rules.
-f FILERecords to write. - reads standard input.
-m WHYReason recorded with the change.
-dry-runPrints the changes without storing a version.

The result is validated. Unknown address lists, CEL errors, bad rule IDs and a ban without ban_for are refused, with the field named.

Record fields by list:

  • access: name, when {paths, path_regex, methods, ip_lists, not_ip_lists, cidrs, countries, not_countries}, expr, action (block, log, allow, trust or ban), skip, ban_for, severity.
  • rate_limits: name, when {paths, methods}, limit, per, action (block, log or ban), ban_for, by (client, consumer or all).
  • exceptions: name, comment, when {paths, methods}, ignore_rules, in, limits.request_body, skip_inspection.
  • positive_rules: endpoint ("METHOD /template"), source (manual, the default, or learned), content_types (none for no body), parameters {name, in (path|query|form|multipart|json|xml|header|cookie), type, length {min, max}, required, charset, enum, pattern (RE2, manual rules only)}.

Approving suggestions changes this list too. Dedicated waap learning approve|preview and waap positive rules commands follow in Positive model learning.

The modes and other settings of these modules are application settings, changed with waap apps set:

  • policy.access.mode
  • policy.rate_limits.mode, policy.rate_limits.per_client_concurrency
  • policy.bans.after_blocks, policy.bans.within, policy.bans.for (automatic bans; set all three)
  • policy.signatures.staged_rules.rules, policy.signatures.staged_rules.until
  • policy.trace.client_ips, policy.trace.paths, policy.trace.until

Times are RFC 3339, or a duration from now (72h).

sh
waap rules get -app shop -list access
waap rules set -app shop -list rate_limits -f limits.yaml -dry-run

waap ratelimit suggestions ​

Suggested rate limits, computed from the traffic log. -app NAME is required on every subcommand. Admin guide section 33.13 covers the feature.

sh
waap ratelimit suggestions list -app NAME
waap ratelimit suggestions run -app NAME [-window 24h]
waap ratelimit suggestions accept -app NAME [-m WHY] [-dry-run] ID
waap ratelimit suggestions reject -app NAME ID

list ​

Shows open and decided suggestions: path, suggested limit per minute per client, how many clients and requests it would have affected, and when it was computed. Paths with too little data are shown as skipped.

run ​

Computes suggestions now. -window is 1m to 7d, default 24h. The job also runs daily. run replaces the open suggestions.

accept ​

Adds the suggested rate rule as a new version. Flags come before the ID. The rule is named suggested-ID, applies by client, per 1 minute, with action log. To change the action later, use waap rules set -list rate_limits.

reject ​

Stops the suggestion from being proposed again.

sh
waap ratelimit suggestions accept -app shop -m "adopt suggested limit" 3