Skip to content

Positive model learning ​

The positive model learns what normal requests look like for each endpoint and flags requests that fall outside it. These commands read and change its settings, show what it has learned, and approve or reject the rules it suggests.

Shared flags for all commands:

  • -runtime-dir DIR selects the running node's admin socket. Default: waap under the system temporary directory.
  • -json prints JSON.

Viewers may read. Operators may change settings and reset, within their application scope.

waap learning get ​

Shows the positive model settings: effective values, defaults, explicit settings and limits. Settings use the API's positive section.

sh
waap learning get -app NAME

confirm_anomalies defaults to true. waap learning get -h and waap learning set -h explain confirmation, and how false makes value checks stricter.

sh
waap learning get -app shop

waap learning set ​

Changes settings as a new configuration version. -m records a reason. -dry-run previews without applying. KEY= restores the default.

sh
waap learning set -app NAME [-m WHY] [-dry-run] KEY=VALUE...

Keys:

  • enabled, mode
  • learning.enabled, learning.sample_rate, learning.headers, learning.cookies
  • learning.min_samples, learning.min_clients, learning.min_duration, learning.min_confidence, learning.fold_threshold
  • unknown_endpoints, unknown_parameters: each accepts log (default) or refuse
  • confirm_anomalies
  • staged_rules, staged_until

Confirmation defaults to true. With confirmation on, out-of-profile type, length, charset and enum values are refused only when classified as sqli, xss, path_traversal, cmdi or ssti. Other values are logged as unconfirmed. Confirmed values are never learned. Unconfirmed values stay in a separate drift lane until enough distinct clients and values support learning them.

Turning confirmation off is stricter: value checks refuse without confirmation. The classifier examines the first 4 KiB. See the admin guide, "Enforce the rules", for the markers and limits.

Recorded attacks count as caught_if_confirmed only when the live classifier also recognizes their untransformed snippet. The UI and CLI label this refused if confirmed. Masked, clipped or escaped snippets cannot confirm, so this is a lower bound.

staged_rules lists positive model rule names (pos.param.type, pos.param.*, pos.*) that only log until staged_until. staged_until is a time, or a duration from now such as 168h. Lists are comma-separated, and durations use Go units (for example 72h).

Learning needs both enabled flags. See get for current defaults, allowed values and bounds.

sh
waap learning set -app shop -m "Observe normal traffic" -dry-run enabled=true learning.enabled=true
waap learning set -app shop -m "Observe normal traffic" enabled=true learning.enabled=true
waap learning set -app shop learning.enabled=false
waap learning set -app shop learning.sample_rate=
waap learning set -app shop -dry-run confirm_anomalies=false
waap learning set -app shop confirm_anomalies=false
waap learning set -app shop confirm_anomalies=  # empty value restores the default (on)
waap learning set -app shop -m "Confirm value anomalies" confirm_anomalies=true

To preview strict enforcement before turning confirmation off:

sh
waap learning preview -app shop -no-confirm

waap learning status ​

Shows the learning state:

  • ready when at least one endpoint meets the evidence thresholds
  • endpoint and parameter counts after folding, and the ready endpoints
  • templates before folding, and the fold threshold
  • samples, estimated distinct clients, first and last seen
  • UTC daily samples, content types, parameter overflow
  • this node's result counters since start
  • progress against the sample, client and observed-time thresholds

Progress uses application totals. Use waap learning model to inspect evidence per endpoint. Observations flush every 10 seconds.

sh
waap learning status -app NAME [-json]

waap learning model ​

Without -endpoint, prints an endpoint table: method, template, status, confidence in percent, limiting factor, samples, estimated distinct clients, observed UTC days and parameter count.

Learned {var} segments carry a *. The folds below the table list each folded prefix and its distinct literal value count. The header shows the application state, whether learning is on, build time, ready endpoints, templates before folding and samples.

With -endpoint, it selects one endpoint by its exact method and folded template, separated by a space. Quote the whole argument. It shows:

  • response counts, content types, first and last seen, overflow
  • all four confidence factors and evidence
  • a parameter table: location, name, presence percent, estimated distinct values, observed byte lengths, top three compatible types by count, sensitive and folded marks, and confidence

Sensitive fields show shapes only. Compatible types overlap. Each parameter also shows its profile in words (type, byte length range, required flag, character classes and enum values), a changed mark and evidence. An absent profile shows name only (too few values).

For each parameter with drift, a Drift for LOCATION NAME line shows the values outside the rule, the estimated clients, and whether the lane is accepted into the learned profile. If it is not accepted, the evidence says not learned until ..., with the required values and clients. Acceptance changes the model, but the policy still requires approval. Endpoint and parameter tables are read only.

-json prints the decoded API answer without table annotations: the whole model, or the selected endpoint with params, length buckets, kept enum counts and enforced rules. The full model also includes covering rule references and unobserved rules.

Models are cached for up to one minute per application and settings, so repeat calls can return the same build time. Viewers may use this command.

Paths, parameter names and content types come from client traffic. Table output shows control characters, bidirectional controls and invalid UTF-8 as escapes (\u001b, \xff style). -json keeps the raw values. waap api inventory and waap explain print request paths the same way.

sh
waap learning model -app shop
waap learning model -app shop -endpoint 'GET /products/{var}'
waap learning model -app shop -endpoint 'GET /products/{var}' -json
waap learning model -app shop -runtime-dir /tmp/waap -json

waap learning violations ​

Shows positive model events for the application over 1 to 90 UTC days (default 7):

  • refused and logged counts per day
  • finding counts by rule
  • the top 200 parameters: endpoint, location, name, count, by rule, last seen
  • the newest 50 event samples, with transaction ID, method, path, mode, current endpoint and redacted findings

Parameter overflow reports omitted parameters. Truncated means the summary read only the newest 5,000 events, so its totals are incomplete. Narrow the day window to reduce it.

sh
waap learning violations -app NAME [-days N] [-endpoint 'METHOD /template'] [-json]

-endpoint filters by the current covering rule's method and template. For a learned endpoint covered by a wider rule, use that wider rule's endpoint. Without a covering rule, it matches only the event's exact method and path. Attribution may differ from the rule in force when the event was recorded.

Both violations and model are read only, and viewers may use them.

Every request-derived table field and API error uses visible terminal escapes for control characters and bidirectional controls. -json keeps the API values when decoded. Unsafe terminal characters, including RTL overrides, appear as JSON escapes.

sh
waap learning violations -app shop
waap learning violations -app shop -days 30 -endpoint 'GET /products/{var}'
waap learning violations -app shop -days 1 -json

waap learning event ​

Inspects one positive model event by transaction ID. It prints the time, method, path, mode, the current rule (source, exact or covered match, index), the learned model endpoint and the policy version.

sh
waap learning event -app NAME -id ID [-json]

Each finding shows:

  • its rule ID, and parameter location and name
  • the redacted snippet and message
  • the staged flag
  • the fix kind: edit_param, add_param, edit_endpoint or add_endpoint
  • the parameter index, the enforced rule, and the learned profile when available

These are the current rules, which may differ from the event-time policy. Snippets are redacted and clipped. Do not derive a widened rule from them.

Missing events, other applications' events, and events without positive findings return 404. -app and a non-empty -id are required.

The returned version is the base_version for an event-based API edit. For the existing CLI rule workflow, prepare a reviewed rule file and use waap positive rules edit or add, first with -dry-run. Those commands read their own current rule-list version. The Learning UI opens those same rule forms directly, and offers an exception preview.

sh
waap learning event -app shop -id TRANSACTION_ID
waap learning event -app shop -id TRANSACTION_ID -json

waap learning suggestions ​

Lists the endpoint suggestions.

sh
waap learning suggestions -app NAME [-id ID | -endpoint 'METHOD /template'] [-status new|rejected|approved|manual]

Each row shows the suggestion ID, status, CHANGE, method, template, confidence percent, samples, estimated clients, content types, parameter count, and an in policy mark when a learned rule already exists for that endpoint.

  • approved means its learned rule still fits. manual means a manual rule covers it.
  • The header includes the build time, endpoints still learning, suggestion overflow and stale rejections.
  • The content type none is shown as (no body). An empty list is shown as any, meaning no constraint.
  • CHANGE is new_endpoint, update or folded. It is empty for first suggestions made before any learned rules exist.

-id ID selects one endpoint or parameter suggestion's endpoint. Use -id or -endpoint, not both.

For updates, the detail shows a Current vs proposed rule table: content types, then each parameter's type, length, charset, enum and required flag, with new, widened or unchanged marks. Folded detail lists the literal learned rules it replaces. Whole-endpoint approval deletes them. Parameter-only approval keeps them.

The Removals table shows ID, endpoint, last seen (or no learned request since learning data starts), evidence and status. -status also filters this table. Approve all never removes: use explicit -remove ID flags. An Application change line shows the count, the since time, and up to 20 endpoints to review.

-endpoint selects an exact method and template, quoted together. It shows the endpoint's evidence and parameters: ID, location, name, the proposed rule in words (type, length range in bytes, required or optional, character classes, enum count and values), status, profiled or name only, confidence, evidence, and sensitive shapes only marks. A maximum length of zero means unbounded. A name-only parameter proposes any value, and keeps its required flag.

-status new|rejected|approved|manual filters endpoints in the list, or parameters with -endpoint. An unknown status or malformed endpoint is a usage error. An endpoint without a suggestion returns a failure and points to the model's limiting factor.

-json keeps the API fields and IDs, applying the same endpoint and status selection inside the suggestions list. Without filters it prints the whole API answer. Viewers may read suggestions. Tables escape control characters, bidirectional controls and invalid UTF-8 in templates, parameter names, enums, content types and evidence, using the same terminal protection as model. JSON preserves the decoded values. Suggestions use the model's one-minute cache.

sh
waap learning suggestions -app shop
waap learning suggestions -app shop -status rejected
waap learning suggestions -app shop -id UPDATE_ID
waap learning suggestions -app shop -endpoint 'GET /products/{var}' -status new
waap learning suggestions -app shop -json -runtime-dir /tmp/waap

waap learning reject ​

Remembers the rejection of one or more endpoint or parameter profiles, or of unused rule removals. Operators only.

sh
waap learning reject -app NAME -id ID [-id ID ...]
  • Use IDs from the suggestions list, detail or JSON. Repeat -id for each ID, at most 1,000 non-empty IDs per call.
  • A name-only parameter has no profile to reject (422). An unknown ID is also 422.
  • An endpoint can be rejected even if it includes name-only parameters.
  • The command does not prompt. It prints the returned suggestion list, or the API answer with -json.
  • The policy stays as it is. Decisions are audited and survive learning resets.
  • A rejection holds while the learned profile fits it. Changes can make the suggestion new again.
  • At most 5,000 rejection decisions are kept per application.
sh
waap learning reject -app shop -id ENDPOINT_ID -id PARAMETER_ID
waap learning reject -app shop -id REMOVAL_ID  # keep the unused rule
waap learning reject -app shop -id PARAMETER_ID -json -runtime-dir /tmp/waap

waap learning restore ​

Removes remembered rejections explicitly, and shows the returned suggestions. Operators only. The same repeatable -id flag and the 1,000-ID limit apply. There is no confirmation prompt.

sh
waap learning restore -app NAME -id ID [-id ID ...] [-json] [-runtime-dir DIR]
  • If none of the IDs is rejected, the API returns 404.
  • Saved IDs can remove stale rejections, even when no current suggestion has that ID.
  • Restore accepts removal IDs too.
  • Restore does not approve a rule, and does not remove one.
sh
waap learning restore -app shop -id ENDPOINT_ID -id PARAMETER_ID
waap learning restore -app shop -id REMOVAL_ID
waap learning restore -app shop -id STALE_ID -json

waap learning approve ​

Approves suggestions, or removes rules. Operators only.

sh
waap learning approve -app NAME [-id ID ... | -all | -f FILE] [-remove ID ...] [-m WHY] [-dry-run]

Selection:

  • -id: endpoint or parameter suggestion IDs, repeatable, 1 to 1,000 non-empty IDs.
  • -all: all new suggestions.
  • -f FILE: a YAML or JSON list of edited rules.

Choose at most one of those selection forms. Add -remove ID (repeatable, at most 1,000 non-empty IDs) for explicit removal suggestions. It also works alone, or with -dry-run. At least one selection or removal is required.

  • -all alone never removes. -all -remove ID approves new suggestions and that named removal, as the API permits.
  • Approving and removing the same endpoint in one request returns 422.
  • Rejected removals must be restored first.
  • Edited suggestions stay learned.
  • -m records a reason.
  • -dry-run prints the policy diff without applying. Otherwise the command prints the active version and the changes.
  • -json prints the changes for a dry run, or the apply result.
  • Files must contain one document, and reject unknown fields. Diff text and errors use terminal escapes.

The CLI reads the suggestions' version and sends it as base_version. A stale version gives 409. The command then shows the error, re-reads the suggestions, and exits with failure. Review the suggestions and impact again, then retry explicitly. The CLI never retries approval automatically.

Manual coverage, rejected or unknown IDs, and nothing new under -all give 422.

sh
waap learning approve -app shop -id ENDPOINT_ID -id PARAMETER_ID -m "Reviewed" -dry-run
waap learning approve -app shop -id ENDPOINT_ID -id PARAMETER_ID -m "Reviewed"
waap learning approve -app shop -all -dry-run
waap learning approve -app shop -remove REMOVAL_ID -dry-run
waap learning approve -app shop -remove REMOVAL_ID -m "Endpoint retired"
waap learning approve -app shop -f edited-rules.yaml -m "Widen note length"

waap learning preview ​

Previews what a selection would do to traffic. Read only; viewers may use it.

sh
waap learning preview -app NAME [-id ID ... | -all | -f FILE] [-remove ID ...] [-days N] [-refuse-unknown-endpoints] [-refuse-unknown-parameters] [-no-confirm]
  • The optional selection matches approval. An empty selection evaluates the policy's current rules.
  • Repeatable -remove ID previews explicit removals, including alongside another selection.
  • -days: 1 to 90 UTC days, default 7.
  • -refuse-unknown-endpoints and -refuse-unknown-parameters preview those settings as refuse.
  • -no-confirm previews value refusals without attack confirmation.
  • Other settings keep the policy's values. Overrides affect only this preview.

The output prints requests, refused and logged ranges (min-max), the upper-bound rate in percent, unknown endpoints and requests, and changed endpoints. Endpoint tables include matched rules, samples, ranges and violations (rule ID, location and name, count, action, expectation). ~ marks an inexact upper-bound count. Manual patterns are unchecked.

Recorded attacks report examined, caught, refused if confirmed (caught_if_confirmed in JSON), logged, counts by rule, and samples (ID and time, request, original module and rule, positive rule, parameter, action, expectation). Attack estimates are lower bounds from redacted events. All request-derived table text is terminal-safe.

-json prints the API answer. -runtime-dir DIR selects the admin socket.

sh
waap learning preview -app shop
waap learning preview -app shop -all -days 30 -refuse-unknown-endpoints
waap learning preview -app shop -f edited-rules.yaml -refuse-unknown-parameters -no-confirm -json

waap positive rules list ​

Lists the learned and manual rules: endpoint, source, content types, and parameters with their constraints and patterns. Empty content types accept any value. none means no body. -json returns the rule array, without the management API's version and items wrapper.

sh
waap positive rules list -app NAME [-json]

Viewers may list. Operators may change rules.

waap positive rules add ​

Adds one rule from a YAML or JSON file. The file holds a single mapping, not a list. If source is omitted, it defaults to manual.

sh
waap positive rules add -app NAME -f FILE [-m WHY] [-dry-run]

Fields: endpoint, source, content_types, parameters.

Each parameter has:

  • name
  • in: path, query, form, multipart, json, xml, header or cookie
  • type (optional)
  • length: {min, max} in bytes (max 0 is unbounded)
  • required, charset, enum
  • pattern: RE2, manual rules only

See the admin guide for validation and bounds. An existing endpoint is an error.

sh
waap positive rules add -app shop -f one-rule.yaml -m "Manual endpoint" -dry-run
waap positive rules add -app shop -f one-rule.yaml -m "Manual endpoint"

waap positive rules edit ​

Replaces the exact existing rule with the single mapping in FILE, including its endpoint and source. If source is omitted, it defaults to manual. The endpoint may be renamed. Other entries stay in order and unchanged. A missing target is an error.

sh
waap positive rules edit -app NAME -endpoint 'METHOD /template' -f FILE [-m WHY] [-dry-run]
sh
waap positive rules edit -app shop -endpoint 'POST /api/orders/{id}' -f one-rule.yaml -dry-run

waap positive rules remove ​

Removes the exact existing rule. A missing target is an error.

sh
waap positive rules remove -app NAME -endpoint 'METHOD /template' [-m WHY] [-dry-run]

add, edit and remove read the rule list's own version, modify the list, and write it with that base_version. A concurrent policy change gives 409. Review the list, then repeat explicitly.

  • -m records a reason.
  • -dry-run prints the changes.
  • -json prints the changes or the apply result.
  • Files must contain one YAML or JSON document, and reject unknown fields.

The whole-list alternative is waap rules get|set -list positive_rules.

sh
waap positive rules remove -app shop -endpoint 'POST /api/orders/{id}' -m "Retired endpoint"

waap learning reset ​

Deletes observations on every node and starts enabled learning again. Settings, rules and remembered rejections stay.

sh
waap learning reset -app NAME [-yes]

It prompts for the exact answer yes. Anything else cancels. -yes skips the prompt for scripts. It does not reset node result counters.

sh
waap learning reset -app shop