the gate's claim about its own writes was false, and the gate now counts it
ci / lint the workflow and the shell (push) Successful in 8s
ci / build, test, smoke (push) Successful in 1m45s
ci / the operator page in a real browser (push) Successful in 2m12s
ci / the same smoke on an image with no base (push) Successful in 4m20s
ci / build the image and smoke it (push) Successful in 4m20s
ci / lint the workflow and the shell (push) Successful in 8s
ci / build, test, smoke (push) Successful in 1m45s
ci / the operator page in a real browser (push) Successful in 2m12s
ci / the same smoke on an image with no base (push) Successful in 4m20s
ci / build the image and smoke it (push) Successful in 4m20s
a8f440b wrote that the gate's admin writes go through `admin_write`. Measured
against the same file an hour later: of its 60 writes that do not go through
`admin`, 34 did — 25 still answered through the un-retried `code` and one went
straight to `curl`. The other 91 writes and 157 reads went through `admin`, which
carried no part of OPEN-39's rule at all: a read that reached nothing answered
NO_JSON_BODY and the log said nothing about why, because the sentinel names the
missing body, not the missing request. The dead-edge scene asserted the opposite
of the fix — that those dead reads write no line to stderr — so the gate was not
only un-instrumented there, it was guarding the missing instrument.
Call sites, counted on this file with comment lines excluded: 261 `admin` (91
writes, 157 reads, 8 carrying -D/-o/-w), 59 `admin_write`, 139 `code`.
What changed:
* `curl_retry` puts OPEN-39's rule under the body-returning helpers. A transport
failure is retried three times and each retry prints the container it sampled;
an HTTP answer — 400, 403, 500 — is an answer and comes back after one attempt.
`admin` and a new `body`, for the scenes that carry their own token, sit on it.
* the body comes back byte for byte. `$(curl ...)` strips trailing newlines and
the six-parallel-POSTs scene writes six `%{http_code}` lines into one shared
file; a wrapper that re-printed carelessly would have turned that assertion
into "204204204204204204". The exit status rides in on a marker suffix instead
of riding on the output.
* the 25 and the 1 joined `admin_write`.
* the dead-edge assertion asks for the nine diagnosis lines and for the absence
of a traceback instead of for silence. It also carried the bug that hid the gap
for one run: `a | b 2>f` captures only b's stderr, so the first version read
back an empty file while the nine lines went to the terminal.
* the claim is now a gate: the file greps its own source and goes red, printing
the count, if any write answers through the un-retried status helper or goes
straight to curl — and fails closed when it cannot read itself.
Three assertions added, one removed: 375 -> 379.
Measured. compose-smoke 379 passed / 0 failed at load average 12 (21:07,
/tmp/compose-retry2.log); that run is one comment rewrap away from this text, and
the two self-audit greps were re-run against the committed file and answer 0 and 0.
readme-counts agrees against that run's totals (379=379, exit 0). shellcheck 0.11.0
and bash -n clean. The retry was again proved against a stub rather than a caught
flake: unreachable twice then a body -> two diagnosis lines and the body's trailing
newline intact (xxd: 610a 620a); always unreachable -> three lines and an empty
body; a 400 -> none; a body ending in `x` -> returned unchanged.
Not measured green: this text against the scratch image. The shared host has held
load average 26-72 since 21:10 and four runs of this tree went red on it — 375/4
at load 31, 377/2 at load 39, 378/1 at load 48 — with every failure in a scene that
reads a projection right after a write that was answered: the two alert-escalation
scenes, and once "the shipped story names the block, the covering range and the
exemption, oldest first" in a run where both alert scenes were green. No `000` near
any of them, and the same tree at load 10-12 was 379/0. That is OPEN-78, filed
today; the README's Gates section now carries those red numbers instead of a green
one it does not have.
This commit is contained in:
@@ -267,7 +267,7 @@ jobs:
|
||||
- name: README assertion counts match what the gate ran
|
||||
run: ./scripts/ci-gates.sh readme-counts scripts/compose-smoke.sh
|
||||
|
||||
# The same stack, the same 375 assertions, and an image whose base is nothing:
|
||||
# The same stack, the same 379 assertions, and an image whose base is nothing:
|
||||
# scratch plus the shared objects the program was linked against, the NSS
|
||||
# modules getaddrinfo needs, OpenSSL, and the CA bundle. This is the job that
|
||||
# answers "will it behave on a production host" for that shape — the first
|
||||
|
||||
@@ -333,7 +333,7 @@ after a rebuild**. Measured on 2026-10-01: the same rebuilt image reported
|
||||
`docker volume rm openwaf_openwaf-geoip`. That is the command to reach for when
|
||||
the pin moves.
|
||||
|
||||
### Two images, one program, and the same 375 assertions against both
|
||||
### Two images, one program, and the same 379 assertions against both
|
||||
|
||||
`Dockerfile` ships the edge on `aspnet:10.0-noble-chiseled`: a distroless
|
||||
runtime, no shell, no package manager. `Dockerfile.scratch` ships the same
|
||||
@@ -350,9 +350,13 @@ same **12** shared objects and **19.9 MB**, scratch **218 MB** against chiseled
|
||||
**258 MB**. `scripts/compose-smoke.sh` runs unchanged against either image — the
|
||||
only change is the `docker-compose.scratch.yml` override — and it answered
|
||||
**368 passed, 0 failed** on both architectures. Re-measured on the same arm64
|
||||
host the evening of 2026-10-06, against the 375-assertion version of this gate:
|
||||
**375 passed, 0 failed** against the chiseled image and **375 passed, 0 failed**
|
||||
against scratch.
|
||||
host the evening of 2026-10-06, against the 379-assertion version of this gate:
|
||||
**379 passed, 0 failed** against the chiseled image at load average 12. Against
|
||||
scratch this revision is not green here yet, and the README says so rather than
|
||||
borrowing the other image's number: the shared host has held load average 26–48
|
||||
since that run, and the scratch runs came back **377 passed, 2 failed** at load 39
|
||||
and **378 passed, 1 failed** at load 48 — every failure in the load-sensitive
|
||||
scenes named below (OPEN-78), none in the instruments this revision changed.
|
||||
|
||||
The assertions are the reason the second Dockerfile is worth having, and the
|
||||
first scratch image built here is the reason they were needed: it started, its
|
||||
@@ -368,7 +372,7 @@ by application code."* A healthy container was not a working edge.
|
||||
|
||||
```
|
||||
scripts/ci-gates.sh scratch-image # build it, print both images' sizes
|
||||
scripts/ci-gates.sh scratch-smoke # the 375, against it
|
||||
scripts/ci-gates.sh scratch-smoke # the 379, against it
|
||||
```
|
||||
|
||||
And the fully static shape, measured the same day rather than argued:
|
||||
@@ -1745,7 +1749,7 @@ cannot mean different things.
|
||||
|
||||
```
|
||||
scripts/ci-gates.sh all # restore, build, unit, integration, smoke, both images, both smokes
|
||||
scripts/ci-gates.sh scratch-smoke # the 375, against the image with no base
|
||||
scripts/ci-gates.sh scratch-smoke # the 379, against the image with no base
|
||||
scripts/ci-gates.sh unit # or any one gate on its own
|
||||
scripts/ci-gates.sh console # the page, in a real Chromium (not part of `all`)
|
||||
```
|
||||
@@ -1869,6 +1873,26 @@ mean: a read that did not parse prints `-1` where a real zero would sit, and bot
|
||||
of those runs printed `0`, so in the first the reads answered and agreed — what
|
||||
was missing was the requests, or the rows, not the parse.
|
||||
|
||||
The family came back the same evening, one level away from transport. Four runs of
|
||||
the 379-assertion tree went red on the shared host at load average 31, 39, 48 and
|
||||
31 — **375/4**, **377/2**, **378/1** — and every failure sat in a scene that reads
|
||||
a projection right after a write that was answered. Three of them were the two
|
||||
alert-escalation scenes: `alert rows for 12 server errors at N=3: 0` and `1` where
|
||||
3 were expected, `candidate_ban rows for 10 refusals at N=3: 0` and `1` where 2
|
||||
were expected. No `000` anywhere near them: the twelve 502s were answered, the same
|
||||
scene's own ban assertions passed, and `settle_alerts` reported a settled number —
|
||||
zero rows, three reads in a row. So the requests happened and the escalation
|
||||
arithmetic still under-reported. The fourth was a different scene with the same
|
||||
shape: `the shipped story names the block, the covering range and the exemption,
|
||||
oldest first` read `no` at load 48 in a run where both alert scenes were green —
|
||||
three writes answered `204 204 204`, and the history read taken immediately after
|
||||
them was missing one of the four events it names.
|
||||
|
||||
That is not OPEN-77's shape and it has its own item now (OPEN-78): each scene
|
||||
asserts only the final answer, so none of them can tell "the projection had not
|
||||
caught up" from "the product never recorded it". The same tree at load average 10
|
||||
and 12 was **379 passed, 0 failed** with those scenes reading 3 and 2.
|
||||
|
||||
A write that never reached the edge is now retried, and the retry is said out
|
||||
loud. `code`'s `000` is the gate failing to reach the stack (OPEN-39), and for a
|
||||
write that is worse than a wrong number: every assertion after it measures a
|
||||
@@ -1891,7 +1915,32 @@ that is really stopped — the write still answers `000`, and it says so three
|
||||
times — because neither green run printed a retry line at all: the host was
|
||||
quiet, and a rule like this is gated by a scene that makes the condition happen,
|
||||
not by waiting to catch one. Two assertions, three bare `next()` reads given the
|
||||
sentinel treatment OPEN-48 wrote for `jval`, and the gate's total is **375**.
|
||||
sentinel treatment OPEN-48 wrote for `jval`, and the gate's total moved to **375**.
|
||||
|
||||
The claim that paragraph made was false, and the gate now counts it. `a8f440b`
|
||||
wrote that the gate's admin writes go through `admin_write`. Measured against the
|
||||
same file an hour later: of its 60 writes that do not go through `admin`, 34 went
|
||||
through the helper, 25 still answered through the un-retried `code` and one went
|
||||
straight to `curl`; and the other 91 writes and 157 reads went through `admin`,
|
||||
which carried no part of OPEN-39's rule at all — a read that reached nothing
|
||||
answered `NO_JSON_BODY` and the log said nothing about why, because the sentinel
|
||||
names the missing body, not the missing request. The dead-edge scene asserted the
|
||||
opposite of the fix: that those dead reads write **no line to stderr**, which is
|
||||
the gate agreeing to be blind. So `admin` now sits on the same retry as
|
||||
`admin_write` — three retries on a transport failure, each printing the container
|
||||
it sampled, an HTTP answer returned after one attempt — the 25 and the 1 joined
|
||||
the helper, and that assertion asks for the nine diagnosis lines and for the
|
||||
absence of a traceback instead of for silence. The body comes back byte for byte:
|
||||
`$(curl …)` strips trailing newlines, and the six-parallel-POSTs scene writes six
|
||||
`%{http_code}` lines into one shared file, which a wrapper that re-printed the
|
||||
body carelessly would have collapsed into `204204204204204204`. And the claim
|
||||
itself is now a gate: the file greps its own source and goes red, printing the
|
||||
count, if any write answers through the un-retried status helper or goes straight
|
||||
to curl — because a sentence about the gate is worth exactly what asserts it.
|
||||
Three assertions added, one removed, 375 → **379**; the retry itself was again
|
||||
proved against a stub (`000` twice then a body: two diagnosis lines, the body's
|
||||
trailing newline intact; an unreachable edge: three lines and an empty body; a
|
||||
`400`: none), and again neither green run needed it — the host was quiet.
|
||||
|
||||
The README's own numbers became a gate. `scripts/ci-gates.sh readme-counts
|
||||
scripts/<gate>` compares the assertion count the README prints for a gate with the
|
||||
@@ -2325,7 +2374,7 @@ dotnet/
|
||||
OpenWaf.Tests.Unit/ 378 tests over the decision logic, the budget window, the refusal wording, the schema baseline and the durability counters
|
||||
OpenWaf.Tests.Integration/ 405 tests driving the real pipeline against a fake upstream
|
||||
scripts/smoke.sh 256 assertions against a running edge + a real upstream
|
||||
scripts/compose-smoke.sh 375 assertions against the built image (compose + nginx)
|
||||
scripts/compose-smoke.sh 379 assertions against the built image (compose + nginx)
|
||||
scripts/console-check.cjs 168 assertions against the page, in a real Chromium
|
||||
scripts/geo-db-freshness.sh the pinned geo database vs the vendor (0/1/2)
|
||||
.github/workflows/ci.yml runs the gates on every push
|
||||
|
||||
+1
-1
@@ -268,7 +268,7 @@ case "${1:-all}" in
|
||||
# same invocation.
|
||||
export GATE_TOTALS_DIR="${GATE_TOTALS_DIR:-$(mktemp -d)}"
|
||||
restore; build; unit; integration; schema-script; smoke; image; compose_smoke
|
||||
# The scratch image and the same 375 assertions against it. It is in `all`
|
||||
# The scratch image and the same 379 assertions against it. It is in `all`
|
||||
# because it is the shipped shape, not an experiment: the only difference a
|
||||
# caller can see is what is under the program.
|
||||
scratch_image; scratch_smoke
|
||||
|
||||
+102
-32
@@ -34,7 +34,41 @@ check() {
|
||||
if [ "$2" = "$3" ]; then PASS=$((PASS+1)); printf ' ok %-54s %s\n' "$1" "$3"
|
||||
else FAIL=$((FAIL+1)); printf ' FAIL %-54s expected %s, got %s\n' "$1" "$2" "$3"; fi
|
||||
}
|
||||
admin() { curl -s -m 10 -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$@"; }
|
||||
# The body-returning half of the gate's instruments. `code` asks curl for the
|
||||
# status and throws the body away; `admin` and `body` keep the bytes, and until
|
||||
# now neither of them carried OPEN-39's rule at all. Measured on this file before
|
||||
# the change: of its 60 writes that answer with a status code, 34 went through
|
||||
# `admin_write`, 25 answered through the un-retried `code` and one went straight
|
||||
# to curl; and 91 writes plus 157 reads went through `admin`, which printed
|
||||
# nothing at all when the request never reached the stack. So a read that hit nothing answered NO_JSON_BODY and the log
|
||||
# said nothing about why — the sentinel names the missing body, not the missing
|
||||
# request. Same rule as `admin_write`, one place: a transport failure is retried
|
||||
# three times and each retry prints the container's own state; an HTTP answer —
|
||||
# 400, 403, 500 — is an answer and comes back after one attempt.
|
||||
#
|
||||
# The trailing bytes are preserved on purpose. `$(curl …)` strips trailing
|
||||
# newlines, and one caller writes six `%{http_code}\n` lines into one shared file
|
||||
# from six parallel POSTs; a helper that re-printed the body without its newline
|
||||
# would turn that assertion into "204204204204204204". So the exit status rides
|
||||
# in on a marker suffix and the body is handed back byte for byte.
|
||||
curl_retry() {
|
||||
local n=0 out rc
|
||||
while :; do
|
||||
out=$(curl -s -m 10 "$@"; printf 'x%s' "$?")
|
||||
rc=${out##*x}
|
||||
out=${out%x*}
|
||||
if [ "$rc" = 0 ] || [ "$n" -ge 3 ]; then break; fi
|
||||
n=$((n + 1))
|
||||
printf ' info the request reached nothing: attempt %s of 4 (curl exit %s), the edge reports %s\n' \
|
||||
"$n" "$rc" "$(edge_state)" >&2
|
||||
sleep 2
|
||||
done
|
||||
printf '%s' "$out"
|
||||
}
|
||||
admin() { curl_retry -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$@"; }
|
||||
# The same read/write with no token of the gate's own, for the scenes that carry
|
||||
# their own (the read-only token, the capability export).
|
||||
body() { curl_retry "$@"; }
|
||||
# jcount/jget evaluate a python expression over the JSON on stdin. `b`/`o` is
|
||||
# the list, and the predicate is written once here instead of being re-sedged
|
||||
# per assertion — sed over JSON silently returns the first match of anything.
|
||||
@@ -373,7 +407,7 @@ echo '- a redirect target the edge cannot send is refused before it is written'
|
||||
CRLF_SRC=203.0.113.246
|
||||
JS_SRC=203.0.113.247
|
||||
check 'a target with a CRLF in it is refused, not stored' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$CRLF_SRC\",\"reason\":\"crlf target\",\"redirectTo\":\"http://x.invalid/\\r\\nX-Injected: 1\"}" \
|
||||
"$EDGE/admin-api/blocks")"
|
||||
# The body is captured first and matched without a pipe into grep -q. Under
|
||||
@@ -394,10 +428,10 @@ case "$REFUSED_TARGET" in
|
||||
esac
|
||||
check 'and the refusal names the field it refused' 'yes' "$names_field"
|
||||
check 'a javascript: target is refused too' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$JS_SRC\",\"redirectTo\":\"javascript:alert(1)\"}" "$EDGE/admin-api/blocks")"
|
||||
check 'a relative target is refused too' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$JS_SRC\",\"redirectTo\":\"not-a-url\"}" "$EDGE/admin-api/blocks")"
|
||||
check 'neither address was written as a block at all' '0' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" \
|
||||
@@ -596,19 +630,19 @@ WRITE_SRC=203.0.113.251
|
||||
POLICY_BEFORE=$(admin "$EDGE/admin-api/policy" | jval streakThreshold)
|
||||
printf ' info the policy this edge is enforcing before the refused write: streakThreshold=%s\n' "$POLICY_BEFORE"
|
||||
check 'a write refuses a query parameter it never implemented' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$WRITE_SRC\"}" "$EDGE/admin-api/blocks?zzz=1")"
|
||||
check 'and the ban it refused was never written' '0' \
|
||||
"$(admin "$EDGE/admin-api/blocks?source=operator" | jcount "b['sourceKey']=='$WRITE_SRC'")"
|
||||
check 'the same write with no unknown parameter is served' '204' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$WRITE_SRC\"}" "$EDGE/admin-api/blocks")"
|
||||
check 'a delete whose scope is misspelled is refused, not run' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE \
|
||||
"$EDGE/admin-api/blocks?key=$WRITE_SRC&src=operator")"
|
||||
check 'and the row it was asked to remove is still there' '1' \
|
||||
"$(admin "$EDGE/admin-api/blocks?source=operator" | jcount "b['sourceKey']=='$WRITE_SRC'")"
|
||||
code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT -H 'Content-Type: application/json' \
|
||||
admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT -H 'Content-Type: application/json' \
|
||||
-d '{"streakThreshold":7}' "$EDGE/admin-api/policy?zzz=1" >/dev/null
|
||||
POLICY_AFTER=$(admin "$EDGE/admin-api/policy" | jval streakThreshold)
|
||||
check 'a policy write with an unknown parameter changes nothing' "$POLICY_BEFORE" "$POLICY_AFTER"
|
||||
@@ -634,7 +668,7 @@ printf ' info the policy in force before the refused writes: engineBlockStatus=
|
||||
REFUSED_BODY=$(admin -X PUT -H 'Content-Type: application/json' \
|
||||
-d '{"engineBlockStatus":1000}' "$EDGE/admin-api/policy")
|
||||
check 'a policy value outside its bounds is a 400, not a 200 that changed nothing' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT -H 'Content-Type: application/json' \
|
||||
-d '{"engineBlockStatus":1000}' "$EDGE/admin-api/policy")"
|
||||
check 'and the refusal names the key and the range it is outside' 'yes' \
|
||||
"$(printf '%s' "$REFUSED_BODY" | grep -q 'engineBlockStatus must be 400..599; got 1000' && echo yes || echo no)"
|
||||
@@ -705,7 +739,7 @@ case "$BOGUS" in
|
||||
esac
|
||||
check 'and echoes back the value it refused' 'yes' "$echoes_value"
|
||||
check 'a delete with that provenance is refused too' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=enigne")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=enigne")"
|
||||
check 'and the operator list is still the two rows it was' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" | jcount "b['source']=='operator'")"
|
||||
check 'both of them by name, not just by count' '2' \
|
||||
@@ -716,7 +750,7 @@ check 'while the documented filter still answers, spaced and cased' '200' \
|
||||
check 'and that filter returns exactly the two rows it means' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false&source=operator" | jcount "b['source']=='operator'")"
|
||||
check 'a TTL of zero is refused, not read as never' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_OP\",\"note\":\"zero ttl\",\"expiresInMinutes\":0}" "$EDGE/admin-api/allow")"
|
||||
ZERO_BODY=$(admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_OP\",\"note\":\"zero ttl\",\"expiresInMinutes\":0}" "$EDGE/admin-api/allow")
|
||||
@@ -728,7 +762,7 @@ check 'and the refusal names the range it is outside' 'yes' "$names_range"
|
||||
check 'and the exemption it refused was never written' '0' \
|
||||
"$(admin "$EDGE/admin-api/allow" | jcount "b['match']=='$SRC_OP'")"
|
||||
check 'a negative TTL is refused with the same range' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_OP\",\"note\":\"negative ttl\",\"expiresInMinutes\":-5}" "$EDGE/admin-api/allow")"
|
||||
admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_TTL\",\"note\":\"no ttl field\"}" "$EDGE/admin-api/allow" >/dev/null
|
||||
@@ -1302,13 +1336,13 @@ JUNK_BEFORE=$(admin "$EDGE/admin-api/countries" | jcount "b['code']=='12' or b['
|
||||
printf ' info junk rows in the country table before this scene: %s\n' "$JUNK_BEFORE"
|
||||
check 'no two-character junk is sitting in the country table already' '0' "$JUNK_BEFORE"
|
||||
check 'a two-character non-code is refused, not stored' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/12?allowed=false")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/12?allowed=false")"
|
||||
check 'and the refusal names the rule and the value' 'code must be a two-letter ISO country code; got "12"' \
|
||||
"$(admin -X PUT "$EDGE/admin-api/countries/12?allowed=false" | jval error)"
|
||||
check 'punctuation of the right length is refused too' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/U.?allowed=false")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/U.?allowed=false")"
|
||||
check 'and so is a question mark, sent as a path and not as a query' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/%3F%3F?allowed=false")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/%3F%3F?allowed=false")"
|
||||
check 'a three-letter code is refused by the same sentence, not by its length' 'two-letter ISO country code' \
|
||||
"$(admin -X PUT "$EDGE/admin-api/countries/USA?allowed=false" | jval error | grep -o 'two-letter ISO country code')"
|
||||
check 'and none of the four wrote a row' '0' \
|
||||
@@ -1321,13 +1355,13 @@ code -H "$(xff "$GEO_IP")" "$EDGE/no-such-page" >/dev/null
|
||||
check 'a refused write leaves the rule that was already there alone' '1' \
|
||||
"$(admin "$EDGE/admin-api/countries" | jcount "b['code']=='$COUNTRY' and b['isAllowed'] is False")"
|
||||
check 'lower case on the wire becomes the rule, not a second row' '204' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/$(printf '%s' "$COUNTRY" | tr '[:upper:]' '[:lower:]')?allowed=false")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT "$EDGE/admin-api/countries/$(printf '%s' "$COUNTRY" | tr '[:upper:]' '[:lower:]')?allowed=false")"
|
||||
check 'and the table holds the upper-case code, never the one typed' 'yes' \
|
||||
"$([ "$(admin "$EDGE/admin-api/countries" | jcount "b['code']=='$COUNTRY'")" = "1" ] && [ "$(admin "$EDGE/admin-api/countries" | jcount "b['code']=='$(printf '%s' "$COUNTRY" | tr '[:upper:]' '[:lower:]')'")" = "0" ] && echo yes || echo no)"
|
||||
check 'the normalised rule is the one the engine enforces' '451' \
|
||||
"$(code -H "$(xff "$GEO_IP")" "$EDGE/no-such-page")"
|
||||
check 'removing the rule answers 204' '204' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/$COUNTRY")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/$COUNTRY")"
|
||||
check 'and the table no longer lists it' '0' \
|
||||
"$(admin "$EDGE/admin-api/countries" | jcount "b['code']=='$COUNTRY'")"
|
||||
# The delete has to reach the decision, not only the table: a rule removed from
|
||||
@@ -1336,11 +1370,11 @@ check 'and the table no longer lists it' '0' \
|
||||
check 'the next request is decided without the removed rule' '404' \
|
||||
"$(code -H "$(xff "$GEO_IP")" "$EDGE/no-such-page")"
|
||||
check 'deleting a rule that was never written says so, naming the code' '404' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/ZZ")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/ZZ")"
|
||||
check 'and the sentence is about that code' 'no country rule for "ZZ"' \
|
||||
"$(admin -X DELETE "$EDGE/admin-api/countries/ZZ" | jval error)"
|
||||
check 'a lower-case delete finds the same answer' '404' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/zz")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/zz")"
|
||||
# A delete of a code that was never a code. The handler validates the same way the
|
||||
# write does, but nothing on the image had ever asked (OPEN-49): the four PUT
|
||||
# refusals above were proven, the DELETE path was not, so a delete that skipped
|
||||
@@ -1348,11 +1382,11 @@ check 'a lower-case delete finds the same answer' '404' \
|
||||
# — would have gone unnoticed. The sentence has to be the write's sentence, because
|
||||
# an operator who mistyped a code gets it from whichever half they tried.
|
||||
check 'a delete of a code that was never a code is refused, not run' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/12")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/12")"
|
||||
check 'with the same sentence the write refuses' 'yes' \
|
||||
"$(admin -X DELETE "$EDGE/admin-api/countries/12" | jval error | grep -q 'two-letter ISO country code' && echo yes || echo no)"
|
||||
check 'and a three-letter delete is refused by the same rule' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/USA")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/countries/USA")"
|
||||
check 'the junk that used to be eternal is still not in the table' '0' \
|
||||
"$(admin "$EDGE/admin-api/countries" | jcount "b['code']=='12' or b['code']=='U.' or b['code']=='??' or b['code']=='USA'")"
|
||||
admin -X PUT -H 'Content-Type: application/json' -d '{"geo":"Off"}' "$EDGE/admin-api/policy" >/dev/null
|
||||
@@ -1399,24 +1433,24 @@ for t, ops in (("block_entries", ("INSERT", "UPDATE", "DELETE")),
|
||||
print("triggers:", [r[0] for r in c.execute("SELECT name FROM sqlite_master WHERE type='trigger'")])
|
||||
PYSQL
|
||||
check 'a delete that could not run answers 503, not 200 with a count' '503' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=operator")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=operator")"
|
||||
check 'and the sentence says NOTHING was deleted' 'yes' \
|
||||
"$(admin -X DELETE "$EDGE/admin-api/blocks?source=operator" | jval error | grep -qi 'NOTHING was deleted' && echo yes || echo no)"
|
||||
check 'a delete of one named key answers the same way' '503' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=operator&key=$OPEN26_A")"
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=operator&key=$OPEN26_A")"
|
||||
check 'the blocks the edge could not delete are still in the table' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?source=operator" | jcount "b['source']=='operator'")"
|
||||
check 'a block the storage refused is not blamed on the request' '503' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"ip":"203.0.113.183","reason":"open26 refused"}' "$EDGE/admin-api/blocks")"
|
||||
check 'and the answer says the block is NOT in effect' 'yes' \
|
||||
"$(admin -X POST -H 'Content-Type: application/json' -d '{"ip":"203.0.113.184"}' "$EDGE/admin-api/blocks" \
|
||||
| jval error | grep -qi 'NOT in effect' && echo yes || echo no)"
|
||||
check 'and it is not the 400 a validation error would use' 'yes' \
|
||||
"$([ "$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
"$([ "$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"ip":"203.0.113.185"}' "$EDGE/admin-api/blocks")" != "400" ] && echo yes || echo no)"
|
||||
check 'a policy change the storage refused is not reported as applied' '503' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT -H 'Content-Type: application/json' \
|
||||
"$(admin_write -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X PUT -H 'Content-Type: application/json' \
|
||||
-d '{"streakThreshold":7}' "$EDGE/admin-api/policy")"
|
||||
check 'and the answer says the change is NOT in effect' 'yes' \
|
||||
"$(admin -X PUT -H 'Content-Type: application/json' -d '{"streakThreshold":7}' "$EDGE/admin-api/policy" \
|
||||
@@ -1694,7 +1728,7 @@ check 'the read-only token reads the shipped block list' '200' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_READ_ONLY_TOKEN" "$EDGE/admin-api/blocks")"
|
||||
check 'the read-only token can scrape the shipped numbers' '200' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_READ_ONLY_TOKEN" "$EDGE/metrics")"
|
||||
RO_WRITE=$(curl -s -m 10 -X POST -H "X-Admin-Token: $OPENWAF_READ_ONLY_TOKEN" \
|
||||
RO_WRITE=$(body -X POST -H "X-Admin-Token: $OPENWAF_READ_ONLY_TOKEN" \
|
||||
-H 'Content-Type: application/json' -d '{"ip":"203.0.113.181","reason":"must not land"}' \
|
||||
"$EDGE/admin-api/blocks")
|
||||
check 'a read-only token cannot write a block on the shipped image' '403' \
|
||||
@@ -2333,17 +2367,31 @@ check 'and the 000 was counted as an unreachable answer' 'yes' \
|
||||
# describing it as a pass. Asserted against a container that is really stopped,
|
||||
# not against a canned string: the read is the same read every scene above makes.
|
||||
DEAD_READS=$(mktemp "${TMPDIR:-/tmp}/openwaf-dead-reads.XXXXXX")
|
||||
DEAD_JVAL=$(admin "$EDGE/admin-api/state" | jval banWriteFailures 2>"$DEAD_READS")
|
||||
DEAD_JCOUNT=$(admin "$EDGE/admin-api/blocks" | jcount "True" 2>>"$DEAD_READS")
|
||||
DEAD_JGET=$(admin "$EDGE/admin-api/blocks" | jget "True" "sourceKey" 2>>"$DEAD_READS")
|
||||
# The redirection goes on the *pipeline*, not on its last command: `a | b 2>f`
|
||||
# captures only b's stderr, and the first version of this scene wrote the nine
|
||||
# diagnosis lines to the terminal and read back an empty file. The diagnosis is
|
||||
# printed by the first command, so the group is what has to be redirected.
|
||||
DEAD_JVAL=$( { admin "$EDGE/admin-api/state" | jval banWriteFailures; } 2>"$DEAD_READS")
|
||||
DEAD_JCOUNT=$( { admin "$EDGE/admin-api/blocks" | jcount "True"; } 2>>"$DEAD_READS")
|
||||
DEAD_JGET=$( { admin "$EDGE/admin-api/blocks" | jget "True" "sourceKey"; } 2>>"$DEAD_READS")
|
||||
DEAD_CMP=no
|
||||
if count_ge "$DEAD_JVAL" 1 || count_gt "$DEAD_JCOUNT" 0; then DEAD_CMP=yes; fi
|
||||
check 'a dead edge reads as no body, not as a traceback' 'NO_JSON_BODY' "$DEAD_JVAL"
|
||||
check 'a dead edge counts as -1, the sentinel streaks_where already used' '-1' "$DEAD_JCOUNT"
|
||||
check 'and the list-field read says the same thing in the other helper' 'NO_JSON_BODY' "$DEAD_JGET"
|
||||
check 'a comparison on a value that was never read answers no' 'no' "$DEAD_CMP"
|
||||
check 'and none of those reads or comparisons wrote a line to stderr' '0' \
|
||||
"$(wc -l < "$DEAD_READS" | tr -d ' ')"
|
||||
# The sentinel says the body is missing; it never said the request did not happen.
|
||||
# That distinction is OPEN-39's whole point, and the body-returning helper did not
|
||||
# carry it. With the edge stopped these three reads now print nine lines — three
|
||||
# attempts each, each naming the container state it sampled — and not one
|
||||
# traceback. The assertion that used to sit here demanded *silence* on stderr,
|
||||
# which is the gate agreeing to be blind: the diagnosis it now prints is the
|
||||
# thing that made the 2026-10-06 flake readable at all.
|
||||
check 'a read that reached the dead edge says so out loud, three retries each' '9' \
|
||||
"$(grep -c 'the request reached nothing' "$DEAD_READS")"
|
||||
check 'and every one of those lines names the container state it sampled' '9' \
|
||||
"$(grep -c 'the edge reports exited' "$DEAD_READS")"
|
||||
check 'and not one of them is a traceback' '0' "$(grep -c Traceback "$DEAD_READS")"
|
||||
# A write aimed at that same stopped edge, so the retry rule above is a measured
|
||||
# behaviour and not a comment: three retries, said out loud, and the answer the
|
||||
# scene gets is still the honest 000 rather than a code that would let the rest
|
||||
@@ -2368,6 +2416,28 @@ printf ' info the container came back as %s\n' "$ALIVE_STATE"
|
||||
check 'the edge is running and healthy again' 'running/healthy' "$ALIVE_STATE"
|
||||
check 'and the stack answers the upstream again' '404' "$(code "$EDGE/no-such-page")"
|
||||
|
||||
echo "- the gate's own writes all answer through the retry helper"
|
||||
# a8f440b wrote that every admin write in this gate goes through the retry
|
||||
# helper. Measured against this file the same day: 34 of its 60 writes that do not
|
||||
# go through `admin` did, 25 still answered through the un-retried status helper
|
||||
# and one went straight to curl. So the sentence was a claim about the gate, and nothing in the
|
||||
# gate could tell anyone it was false — the same defect this file keeps naming one
|
||||
# level down. The gate now counts its own bypassing write sites by reading its own
|
||||
# source, which is the only way the rule survives the next write someone adds.
|
||||
SELF_PATH=${BASH_SOURCE[0]}
|
||||
if [ -r "$SELF_PATH" ]; then
|
||||
BYPASS_CODE=$(grep -cE '(^|[^_[:alnum:]])code[[:space:]]+[^|]*-X[[:space:]]+(POST|PUT|DELETE)' "$SELF_PATH")
|
||||
BYPASS_CURL=$(grep -cE '(^|[^_[:alnum:]])curl[[:space:]][^|]*-X[[:space:]]+(POST|PUT|DELETE)' "$SELF_PATH")
|
||||
else
|
||||
# Fails closed: an unreadable self is a red assertion, not a vacuous pass.
|
||||
BYPASS_CODE=cannot-read-the-gate-source
|
||||
BYPASS_CURL=cannot-read-the-gate-source
|
||||
fi
|
||||
printf ' info write sites in this file that bypass the retry helper: %s via the status helper, %s via raw curl\n' \
|
||||
"$BYPASS_CODE" "$BYPASS_CURL"
|
||||
check 'no admin write in this gate answers through the un-retried status helper' '0' "$BYPASS_CODE"
|
||||
check 'and none of its writes goes straight to curl' '0' "$BYPASS_CURL"
|
||||
|
||||
echo
|
||||
# The total is printed for the reader, and written where
|
||||
# scripts/ci-gates.sh readme-counts can compare it with the number the README
|
||||
|
||||
Reference in New Issue
Block a user