Files
openwaf/scripts
Pavlo Ratushnyi 0a8d0e7695 Operator console at /admin, over the endpoints that already exist
The admin API has been complete since a3d0777 and an operator still has to
drive it with curl. GET /admin now serves one page: mode and snapshot age, live
bans with their reasons, the sources being watched, and the countries seen.
Every control on it is one call to an existing endpoint — the page decides
nothing, which is the only reason it is safe to put on an edge.

Inherited properties, tested rather than asserted in a comment:
 * /admin is on the always-pass list, so a blocked operator can still reach the
   page that unblocks them (integration test + compose-smoke assertion);
 * the always-pass surface is never observed, so fumbling it builds no streak;
 * the token is typed into the page and sent as a header — never in a URL, where
   it would sit in proxy logs, history and Referer — and the markup is checked
   not to contain it, in the fixture and against the built image.
No external assets: a console that needs a CDN fails exactly when the site
behind the edge is under attack.

One new read endpoint, /admin-api/countries/summary, counting sources and
refusals per country from the observation aggregates — there is no request log
to count, by design.

Two bugs the new tests caught before this was true:
 * "/admin" and "/admin/" are the same route to the matcher — registering both
   is an AmbiguousMatchException, i.e. a 500 on the page; now one endpoint with
   a catch-all, so a mistyped subpath shows the page instead of being proxied to
   an upstream that has never heard of it.
 * the country query compiled and failed at translation time with a record
   constructor; an anonymous projection translates.

Gates on this commit: 36 unit + 19 integration, 0 failed; scripts/smoke.sh
19/19; docker build ok (261 MB); scripts/compose-smoke.sh 27/27, the three new
assertions included.
2026-10-01 11:32:52 +02:00
..