Skip to content

Read WAF data without Athena and wait for the AWS role's reads instead of asking a person - #776

Merged
nambok merged 1 commit into
mainfrom
waf-role-reads-wait
Nov 18, 2026
Merged

nambok merged 1 commit into
mainfrom
waf-role-reads-wait

Conversation

@nambok

@nambok nambok commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

An AWS WAF signature-drift alarm run ended needs_outside_change with "Needed from you: Nothing", a cause labelled "Not checked against the data (no lookups were made)" after five lookups, and a request that a person run an Athena query. Four causes, each closed at the root:

  1. CloudWatch metrics refused AWS/WAFV2 itself ("isn't a namespace Coderhelm reads") although the team's role allows cloudwatch:GetMetricData on everything.
  2. The account's role stack predated the template's WAF reads, and nothing would ever take the run up again once the role could read.
  3. No agent tool could read a WAF rule's matches without Athena, so "which attribute changed" was out of reach.
  4. Only data-source lookups were counted, and a run with nothing left for a person could still end in a status that says a person must act.

Changes

  • common::live::metrics: any namespace is read (CloudWatch's own syntax checked; window, query and dimension caps kept). The list is now NAMESPACE_HINTS for the tool description, with AWS/WAFV2 (WebACL, Rule, Region; CountedRequests, BlockedRequests, AllowedRequests) and other common namespaces added. A CloudFront web ACL's WAF metrics, like CloudFront's, are read in us-east-1; an optional region names another. An AWS access refusal is StepError::role_refused: the install's "AWS role reads" item in one line, recorded for the account, never a refusal of ours.
  • common::waf_logs (new): reads a web ACL's log objects straight from its aws-waf-logs-* bucket (hour prefixes newest first, at most 48 objects, 64 MiB compressed and 512 MiB uncompressed, 24 hours) and groups the rule's matches in process by JA4, user agent, Accept-Language, path and cookie presence, with JA4 prefixes, countries, labels, actions and matches per hour. No client address, cookie or other header value, or query string is kept.
  • common::alarm_evidence: split into reusable reads; the alarm's evidence reads the log objects before it tries Athena (Athena stays optional). New agent tools waf_sampled_requests and waf_log_objects in ops_tools, registered as reads; their refusals are recorded as the install item.
  • plan.rs / fix_location::lookups_made: the monitoring tools' lookups count, so "no lookups were made" appears only when none were.
  • common::role_wait (new) and worker::passes::role_wait (new): finish_without_code ends needs_outside_change only when the final person check leaves an item. With none and role reads refused during this run, the run ends awaiting_setup (new status) with a paragraph saying what it waits for, re-checks the role every 15 minutes for two days, then with the daily role check, and at once when another run reads again. When the reads work, it starts again from its ticket (same sender, so the alarm's evidence is read again) to make the change and open the pull request. With nothing for a person and nothing to wait for, the plan is made again.
  • awaiting_setup is in the run status list, blocks a duplicate trigger, and shows in the chat's waiting group. New worker message role_reads_wait.
  • Incident cx_role_reads_wait_then_finish (doc and test) replays the run's shapes with invented names.

Deferred: the dashboard (separate repository) shows awaiting_setup by its raw name until it gets a label.

Verification

  • cargo fmt --check, rustfmt --check on the incident file, cargo clippy --all-targets -- -D warnings: clean.
  • cargo test (workspace): common 2799, gateway 1083, worker 2250 and the rest pass.
  • New tests: the metrics checks (any namespace, WAF regions, AWS refusal as the role item), waf_logs (key layout, grouping, privacy, bounds, rule groups), role_wait (ending, this run's refusals, readiness with Athena optional), and the incident: with the role lacking WAF reads the run waits and raises the item; with metrics allowed it reads AWS/WAFV2; once the reads work it reads the logs and routes to a code plan.

…d of asking a person

- CloudWatch metrics: any namespace is read; the team's role is the
  boundary. The namespace list is now hints only (AWS/WAFV2 with WebACL,
  Rule, Region and its request counts added). CloudFront web ACL WAF
  metrics read in us-east-1; an AWS access refusal is the install's
  "AWS role reads" item, recorded for the account.
- New agent tools waf_sampled_requests and waf_log_objects: a rule's
  sampled requests, and its matches read straight from the web ACL's
  aws-waf-logs-* objects (bounded, grouped in process by JA4, user agent,
  accept language, path, cookie presence). The alarm evidence reads the
  log objects before trying Athena.
- Every planner lookup counts (monitoring tools included), so "no lookups
  were made" appears only when none were.
- A run whose plan changes no code ends needs_outside_change only when a
  person has an item. With nothing for a person and role reads refused
  this run, it ends awaiting_setup, re-checks the role every 15 minutes
  then daily (and when another run reads again), and starts again from
  its ticket once the role reads. Otherwise it plans again.
- Incident case cx replays the run.
@nambok
nambok merged commit 84485cf into main Nov 18, 2026
10 checks passed
@nambok
nambok deleted the waf-role-reads-wait branch November 18, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant