the gates gain the assertions they were missing, and lint gains a local caller
ci / lint the workflow and the shell (push) Successful in 9s
ci / build, test, smoke (push) Successful in 2m23s
ci / the operator page in a real browser (push) Successful in 2m47s
ci / build the image and smoke it (push) Successful in 4m0s

Four gaps named on the board, each closed by making the shipped image answer the
question instead of an in-process test:

OPEN-45 - three pagination bounds were proven only in-process. On the image now:
the block listing's ceiling at its UPPER end (limit=2001 -> 400 naming
"limit must be 1..2000; got 2001" - only the lower end was on the image), a
negative offset on the streak map (checked on observations, blocks and alerts,
never here), and that an offset on the alert listing moves to a different row -
the scene used to assert only the truncation arithmetic.

OPEN-49 - DELETE /admin-api/countries/{code} validates the code the same way the
write does, and nothing on the image had ever asked. Three checks added: "12" and
"USA" are refused with the write's own sentence, not answered as if a row existed.

OPEN-48 - jval piped the body straight into json.load, so a request that produced
no body printed a Python traceback into the middle of an assertion and the
assertion compared an empty string. "the counter is 0", "the field is missing"
and "there was no answer at all" were the same word in the log. Three states,
three answers now: NO_JSON_BODY, empty, the value.

OPEN-41 - the markup-path assertion read the observation table once. That row is
written by the coalesced observation writer, so its arrival is on a timer: two
runs of one head at 9383362, one failed with `[]` and the next passed, and the
`[]` could not tell "not persisted yet" from "never persisted". The row is waited
for with a 10 s budget, the wait is printed either way, and a failure names what
was waited for and every path cell the table did hold.

OPEN-44 - the workflow files and the smoke scripts were linted by exactly one
caller, a CI job, so `ci-gates.sh all` could be green on a tree CI would refuse.
The pinned actionlint 1.7.12 and shellcheck 0.11.0 (same checksums) move into
scripts/ci-gates.sh as a `lint` gate and the CI job calls it: one definition, two
callers. A host with neither tool and no supported platform exits 2 - "cannot
run" - rather than reporting a pass, the console gate's convention.

Measured on this tree: scripts/ci-gates.sh lint green locally (actionlint 1.7.12,
shellcheck 0.11.0); compose smoke 356 passed / 0 failed, up from 348 by exactly
the eight assertions added above; the console check passed all its assertions
locally against the built image.
This commit is contained in:
Pavlo Ratushnyi
2026-10-06 00:32:28 +02:00
parent 96b1bf1e7e
commit 249e3f93b5
4 changed files with 187 additions and 45 deletions
+14 -39
View File
@@ -90,45 +90,20 @@ jobs:
# The linter itself is pinned to a version and a checksum, not piped from
# a setup script: a gate that can be moved by someone republishing a tag is
# not a gate. actionlint also checks the run: blocks below with shellcheck.
- name: actionlint (pinned, checksum verified)
run: |
VERSION=1.7.12
SHA256=8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
curl -fsSL -o /tmp/actionlint.tar.gz \
"https://github.com/rhysd/actionlint/releases/download/v${VERSION}/actionlint_${VERSION}_linux_amd64.tar.gz"
echo "${SHA256} /tmp/actionlint.tar.gz" | sha256sum -c -
tar xzf /tmp/actionlint.tar.gz -C /tmp actionlint
# Both files, by glob: a workflow added later is linted by the same
# step without anyone remembering to add it to a list.
/tmp/actionlint -no-color .github/workflows/*.yml
# Both smoke scripts are gates, so a broken one has to fail loudly here
# rather than look like a passing run with zero assertions.
#
# The version is pinned the same way actionlint is, because relying on the
# copy baked into the image made the gate's verdict depend on the image:
# ubuntu-latest ships shellcheck 0.9.0-1, and running this file in a local
# actions-compatible runner (nektos/act on catthehacker/ubuntu:act-latest)
# had 0.9.0 flag an `A && B || C` pattern in scripts/geo-db-bump.sh that
# the 0.11.0 developers run locally does not. The script was rewritten as
# an explicit if, and the version is fixed here so the gate says the same
# thing everywhere it runs. The log prints which version did the linting.
- name: shellcheck the smoke scripts (pinned, checksum verified)
run: |
VERSION=0.11.0
SHA_X86_64=8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
SHA_AARCH64=12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588
case "$(uname -m)" in
x86_64) ARCH=x86_64; SHA=$SHA_X86_64 ;;
aarch64) ARCH=aarch64; SHA=$SHA_AARCH64 ;;
*) echo "shellcheck: unsupported architecture $(uname -m)" >&2; exit 1 ;;
esac
curl -fsSL -o /tmp/shellcheck.tar.xz \
"https://github.com/koalaman/shellcheck/releases/download/v${VERSION}/shellcheck-v${VERSION}.linux.${ARCH}.tar.xz"
echo "${SHA} /tmp/shellcheck.tar.xz" | sha256sum -c -
tar xJf /tmp/shellcheck.tar.xz -C /tmp
/tmp/shellcheck-v${VERSION}/shellcheck --version
/tmp/shellcheck-v${VERSION}/shellcheck -s bash scripts/*.sh
# One definition of the lint gate, two callers (OPEN-44). The versions and
# checksums are pinned in scripts/ci-gates.sh, the same file an operator runs
# as `scripts/ci-gates.sh lint` before pushing a workflow or script change —
# so "green locally" and "green here" are the same claim about the same pinned
# tools instead of two definitions that can drift. They were pinned here
# because the copy baked into the image made the verdict depend on the image:
# ubuntu-latest ships shellcheck 0.9.0-1, and a local Actions-compatible runner
# (nektos/act on catthehacker/ubuntu:act-latest) had 0.9.0 flag an `A && B || C`
# pattern in scripts/geo-db-bump.sh that the 0.11.0 the developers run locally
# does not. The script was rewritten as an explicit if and the version fixed,
# and the log prints which version did the linting. The script exits 2 when the
# tools cannot run at all, which fails this job rather than reporting a pass.
- name: actionlint + shellcheck (pinned, checksum verified)
run: ./scripts/ci-gates.sh lint
source:
name: build, test, smoke
+86 -2
View File
@@ -6,6 +6,11 @@
#
# scripts/ci-gates.sh restore|build|unit|integration|smoke|image|compose-smoke|all
# scripts/ci-gates.sh console (needs a real Chromium; not part of `all`)
# scripts/ci-gates.sh lint (the workflow and shell lint CI runs. Not in
# `all` for the console gate's reason: a machine
# that has neither the pinned tools nor a
# supported platform exits 2 — "cannot run" —
# which is a different answer from "clean".)
#
# Not here on purpose: scripts/geo-db-freshness.sh. It asks the vendor what the
# newest geo database is, so it is the one gate that talks to the internet, and
@@ -53,6 +58,82 @@ compose_smoke() { banner compose-smoke; ./scripts/compose-smoke.sh; }
# to the console.
console() { banner console; ./scripts/console-smoke.sh; }
# Checksum helper: sha256sum on Linux, shasum on a macOS host, and a refusal to
# check nothing when neither is present.
sha256_verify() {
if command -v sha256sum >/dev/null 2>&1; then
printf '%s %s\n' "$2" "$1" | sha256sum -c -
elif command -v shasum >/dev/null 2>&1; then
printf '%s %s\n' "$2" "$1" | shasum -a 256 -c -
else
printf 'no sha256 tool on this host: refusing to download an unverified binary\n' >&2
return 2
fi
}
# The lint CI runs. It lives here because until this stage existed the workflow
# files and the smoke scripts were checked by exactly one caller — a CI job — and
# `ci-gates.sh all` could be green on a tree CI would refuse (OPEN-44). The
# versions and checksums are pinned here rather than in the workflow, and the CI
# job now calls this function, so the two callers cannot drift into linting
# different versions of the same gate.
#
# A tool already on PATH is used as it is, and the version it prints is the
# version that did the linting — that is the number the README quotes. Otherwise
# the pinned release is downloaded, which is supported on linux x86_64 and arm64.
# Anywhere else this says so and exits 2: a lint stage that silently passes on a
# machine where it never ran is the defect OPEN-44 is about.
lint() {
banner lint
local workdir; workdir=$(mktemp -d)
if command -v actionlint >/dev/null 2>&1; then
actionlint --version | head -1
actionlint -no-color .github/workflows/*.yml
elif [ "$(uname -s)" = Linux ]; then
local version=1.7.12
local sha=8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
local arch
case "$(uname -m)" in
x86_64) arch=amd64 ;;
aarch64) arch=arm64 ;;
*) printf 'actionlint: unsupported architecture %s — cannot run (exit 2), not a pass\n' "$(uname -m)" >&2; return 2 ;;
esac
curl -fsSL -o "$workdir/actionlint.tar.gz" \
"https://github.com/rhysd/actionlint/releases/download/v${version}/actionlint_${version}_linux_${arch}.tar.gz"
sha256_verify "$workdir/actionlint.tar.gz" "$sha"
tar xzf "$workdir/actionlint.tar.gz" -C "$workdir" actionlint
"$workdir/actionlint" --version | head -1
"$workdir/actionlint" -no-color .github/workflows/*.yml
else
printf 'actionlint is not installed and this is not Linux: the lint gate cannot run (exit 2), which is not a pass\n' >&2
return 2
fi
if command -v shellcheck >/dev/null 2>&1; then
shellcheck --version | sed -n 's/^version: //p'
shellcheck -s bash scripts/*.sh
elif [ "$(uname -s)" = Linux ]; then
local sv=0.11.0
local sv_x86_64=8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
local sv_aarch64=12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588
local sarch ssha
case "$(uname -m)" in
x86_64) sarch=x86_64; ssha=$sv_x86_64 ;;
aarch64) sarch=aarch64; ssha=$sv_aarch64 ;;
*) printf 'shellcheck: unsupported architecture %s — cannot run (exit 2), not a pass\n' "$(uname -m)" >&2; return 2 ;;
esac
curl -fsSL -o "$workdir/shellcheck.tar.xz" \
"https://github.com/koalaman/shellcheck/releases/download/v${sv}/shellcheck-v${sv}.linux.${sarch}.tar.xz"
sha256_verify "$workdir/shellcheck.tar.xz" "$ssha"
tar xJf "$workdir/shellcheck.tar.xz" -C "$workdir"
"$workdir/shellcheck-v${sv}/shellcheck" --version | sed -n 's/^version: //p'
"$workdir/shellcheck-v${sv}/shellcheck" -s bash scripts/*.sh
else
printf 'shellcheck is not installed and this is not Linux: the lint gate cannot run (exit 2), which is not a pass\n' >&2
return 2
fi
}
case "${1:-all}" in
restore) restore ;;
build) build ;;
@@ -62,14 +143,17 @@ case "${1:-all}" in
image) image ;;
compose-smoke) compose_smoke ;;
console) console ;;
lint) lint ;;
all)
restore; build; unit; integration; smoke; image; compose_smoke
printf '\nall gates passed\n'
printf 'NOT included above: console (needs a real Chromium; exits 2 without one).\n'
printf 'NOT included above: console (needs a real Chromium; exits 2 without one),\n'
printf 'and lint (needs actionlint and shellcheck; exits 2 without them).\n'
printf 'If the console changed, run: %s console\n' "$0"
printf 'If a workflow or script changed, run: %s lint\n' "$0"
;;
*)
printf 'usage: %s restore|build|unit|integration|smoke|image|compose-smoke|console|all\n' "$0" >&2
printf 'usage: %s restore|build|unit|integration|smoke|image|compose-smoke|console|lint|all\n' "$0" >&2
exit 2
;;
esac
+54 -1
View File
@@ -93,8 +93,24 @@ xff() { printf 'X-Forwarded-For: %s' "$1"; }
# Booleans are printed as JSON spells them (json.dumps), not as Python spells
# them: the first version of this helper answered `True` and the assertion
# against a JSON `true` failed on the spelling, not on the product.
# Three states, three answers. The first version of this helper piped the body
# straight into json.load, so a request that produced no body at all — a refused
# connection, a container that had just died — printed a Python traceback into the
# middle of an assertion and the assertion compared an empty string (OPEN-48). That
# is the same defect this file keeps naming elsewhere: a gate that answers like a
# measurement when it is really reporting its own failure. So: no body prints
# NO_JSON_BODY, a field the object does not carry prints the empty string, and a
# field that is there prints its value. A wrong assertion still fails, but it fails
# with a value a reader can tell apart from "the field is missing".
jval() { python3 -c "import json,sys
d=json.load(sys.stdin); v=d.get('$1')
s=sys.stdin.read().strip()
if not s:
print('NO_JSON_BODY'); raise SystemExit(0)
try:
d=json.loads(s)
except ValueError:
print('NO_JSON_BODY'); raise SystemExit(0)
v=d.get('$1')
print('' if v is None else (json.dumps(v) if isinstance(v,(bool,int,float)) else v))"; }
# Alerts are counted as a delta (see the alert sections): the data volume
# survives `compose down`, so an absolute count would be history, not this run.
@@ -1034,6 +1050,16 @@ check 'the alert listing carries both headers' 'yes' \
"$(admin -D "$TMPH" -o "$TMPB" "$EDGE/admin-api/alerts?limit=1"; grep -qi '^x-total-count:' "$TMPH" && grep -qi '^x-truncated:' "$TMPH" && echo yes || echo no)"
check 'and its flag agrees with its own arithmetic' 'yes' \
"$(admin -D "$TMPH" -o "$TMPB" "$EDGE/admin-api/alerts?limit=1&offset=1"; truth 1)"
# The flag arithmetic above says a cut happened; it does not say the cut moved the
# window. That gap was OPEN-45's third item: for observations and blocks the image
# proves offset shows a different row, for alerts it proved only the header.
alert_row() { admin "$EDGE/admin-api/alerts?limit=1&offset=$1" \
| python3 -c 'import json,sys; print(json.dumps(json.load(sys.stdin)[0], sort_keys=True))'; }
ALERT0=$(alert_row 0); ALERT1=$(alert_row 1)
printf ' info alert rows at offset 0 and 1 differ: %s\n' \
"$([ "$ALERT0" != "$ALERT1" ] && echo yes || echo no)"
check 'an offset on the alert listing shows a different alert, not the same row again' 'yes' \
"$([ "$ALERT0" != "$ALERT1" ] && echo yes || echo no)"
# The block listing gets exact numbers, because this scene owns the whole
# filtered set: two operator rows and nothing else under source=operator.
admin -X POST -H 'Content-Type: application/json' -d '{"ip":"203.0.113.181","note":"paging-1"}' "$EDGE/admin-api/blocks" >/dev/null
@@ -1071,6 +1097,21 @@ check 'the same negative offset on the block listing' 'offset must be 0 or more;
"$(admin "$EDGE/admin-api/blocks?offset=-1" | jval error)"
check 'and on the alert listing' 'offset must be 0 or more; got -1' \
"$(admin "$EDGE/admin-api/alerts?offset=-1" | jval error)"
# The three bounds OPEN-45 found proven only in-process, now proven on the wire.
# Each one is a case where the answer used to be a row rather than a refusal, and
# the in-process test could pass while the shipped image still served the row: the
# block listing's ceiling at its UPPER end (only the lower end was on the image),
# a negative offset on the streak map (checked on observations, blocks and alerts
# but never here), and — below, in the paging scene — that an offset on the alert
# listing moves to a different row rather than only changing the flag arithmetic.
check 'the block listing refuses a limit above its own ceiling' '400' \
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$EDGE/admin-api/blocks?limit=2001")"
check 'naming its own, wider, range and the value it refused' 'limit must be 1..2000; got 2001' \
"$(admin "$EDGE/admin-api/blocks?limit=2001" | jval error)"
check 'the streak map refuses a negative offset as well' '400' \
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$EDGE/admin-api/streaks?offset=-1")"
check 'and names the parameter it means there too' 'offset must be 0 or more; got -1' \
"$(admin "$EDGE/admin-api/streaks?offset=-1" | jval error)"
# The streak map, with the two counts deliberately different: two sources with
# something standing, one whose run ended on a clean answer and therefore stays
# in the map while the listing leaves it out. That gap is what makes the flag
@@ -1165,6 +1206,18 @@ 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")"
# 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
# validation and answered 404 for "12" — or worse, 204 for a row that never existed
# — 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")"
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")"
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
+33 -3
View File
@@ -261,11 +261,41 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
(bodies) => bodies.reduce((n, b) => n + b.querySelectorAll('img,svg,script,iframe,object,embed').length, 0));
check('no element was created out of a value that came from the API',
injected === 0, `${injected} injected elements`);
const obsCells = await page.$$eval('#obs tbody tr', (rows) =>
rows.map((tr) => [...tr.children].map((td) => td.textContent)));
// The observation row for a seeded request is written by the coalesced
// observation writer, not by the request that made it: one durable upsert per
// source per ObservationWriteInterval. Reading the table once sampled one
// instant and called it a contract. Measured on Linux at 9383362: two runs of
// the same head, one failed with `the markup path is printed as the text it is
// — []` and the next passed, and the `[]` is the whole problem — the driver
// could not tell "not persisted yet" from "never persisted" from "persisted but
// not on this page" (OPEN-41). So the row is waited for with a stated budget,
// and the elapsed wait is printed whether or not it arrived.
//
// The other seed-derived table reads in this driver are already waited for, and
// this is the list of them, because "the same class elsewhere" is the question
// the next reader will ask: the alert row (bounded retry above), the block rows
// (waitForFunction on #blocks tbody), the streak and budget rows, the change-log
// row, and the horizon/story/search rows. What is read once on purpose is the
// escaping invariant itself (no element was created out of an API value): that
// one asks about the DOM at the moment the page is settled, not about a row
// whose arrival is on a timer.
let obsCells = [];
let obsWaitedMs = 0;
const OBS_BUDGET_MS = 10000;
for (;;) {
obsCells = await page.$$eval('#obs tbody tr', (rows) =>
rows.map((tr) => [...tr.children].map((td) => td.textContent)));
if (obsCells.some((r) => (r[4] || '').includes(decoded))) break;
if (obsWaitedMs >= OBS_BUDGET_MS) break;
await new Promise((r) => setTimeout(r, 500));
obsWaitedMs += 500;
}
console.log(` info the observation table was waited ${obsWaitedMs} ms for the seeded markup path`);
check('the markup path is printed as the text it is',
obsCells.some((r) => (r[4] || '').includes(decoded)),
JSON.stringify(obsCells.filter((r) => (r[4] || '').includes('xss-probe')).map((r) => r[4])));
`waited ${obsWaitedMs} ms for a row whose path cell contains ${JSON.stringify(decoded)}; ` +
`the table held ${obsCells.length} rows: ` +
JSON.stringify(obsCells.map((r) => r[4] ?? '')));
}
if (SEED_MARKUP_BLOCK) {
check('a markup block reason is printed as text too',