Files
openwaf/scripts
Pavlo Ratushnyi fc90f50de8 A country rule made of any two characters was stored, shown to the operator, and obeyed by nobody
PUT /admin-api/countries/{code} checked one thing about the code: that it was
two characters long. Measured on the shipped image (openwaf:ci):

  PUT /admin-api/countries/12?allowed=false -> 204
  PUT /admin-api/countries/U.?allowed=false -> 204
  GET /admin-api/countries -> "12: denied", "U.: denied", "US: allowed"
  probe from a source the geo database puts in a real country -> 404

A country rule is matched against the two-letter code the geo database returns,
so "12" and "U." can never match anything: the operator's table said two
countries were denied and the edge enforced nothing. With US denied for real the
same probe answers 451, which is the difference the table was hiding. And there
was no DELETE, so the row was permanent — the console gate's own comment used to
read "a country rule cannot be deleted, only overwritten", and the residue out
lived `compose down` because it lives in the data volume.

Now the code must be two ASCII letters or the write is refused by name:
"code must be a two-letter ISO country code; got \"12\"". DELETE
/admin-api/countries/{code} removes a rule and invalidates the snapshot, and
says `no country rule for "ZZ"` when there is nothing to remove. The page offers
"remove rule" on a row that has a rule, and the gate's cleanup deletes the US
rule it sets instead of leaving it behind.

The country part of the console gate was also fixed, and it was a gate bug worth
naming: it assumed a US rule already existed. With residue in the volume the
first click denied the country; on a fresh volume it allowed it, so the
assertion only ever passed on leftover state. It now starts from no rule and
asserts — → allowed → denied → removed.

Teeth, each reverted and counted, then restored: length-only code check -> 5
integration failures; DELETE endpoint removed -> 2; both out -> 9.

Gates on this tree: unit 128/128, integration 99/99, smoke passed 19 failed 0,
compose 43 passed 0 failed, console 44 assertions 0 failed, image 261 MB.
2026-10-02 03:11:57 +02:00
..