the gates gain the proof their own claims were missing, and the README has to pay for its numbers
compose-smoke.sh: the read-side redirect guard is proven on the shipped image at last — a good target is written through the API, the stored column is rewritten underneath a running edge through the sidecar, and the edge is asked what it sends once the snapshot rebuilds. javascript:alert(1) answers 301 to the policy default and never to the stored value; a CRLF-bearing row answers 301 rather than the 500 Kestrel used to produce, and injects nothing. A curl 000 now samples the container it was aimed at and prints what it reports, and the gate ends by making the dead case happen on purpose: compose stop, 000 beside exited/unhealthy, compose start, running/healthy again. console-check.cjs: the observation table is waited for rather than read at one instant (an act run saw X-Total-Count: 0 where the same head a minute earlier had 11 rows), and the page's own request paths are pinned — the 14 admin-api calls it issues, their query strings, no others, none answered 404. A wrong URL on a page never looks like a wrong URL; it looks like an empty table. ci-gates.sh gains readme-counts: each gate records the total it actually ran into GATE_TOTALS_DIR and the README's claimed number is compared with it. Its first verdict was that the README claimed 229 assertions for a gate printing 368 — a 139-assertion gap nothing could see. The README now says 368 and 168, both measured in this run, and the run-by-run table gains 2405. Verified locally: compose smoke 368/0, console 168/0, smoke 256/0, lint green at actionlint 1.7.12 and shellcheck 0.11.0.
This commit is contained in:
@@ -78,6 +78,10 @@ env:
|
||||
# The compose smoke test needs a token to exercise the admin API. It is not a
|
||||
# secret: it is a throwaway value for a stack that exists only inside the job.
|
||||
OPENWAF_ADMIN_TOKEN: ci-only-throwaway
|
||||
# Where each gate writes the number of assertions it actually ran, so the step
|
||||
# after it can compare that with the number the README claims (OPEN-46). Per
|
||||
# job, not shared: each job runs its own gate and verifies its own number.
|
||||
GATE_TOTALS_DIR: /tmp/openwaf-gate-totals
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -135,6 +139,12 @@ jobs:
|
||||
- name: Smoke — a running edge and a real upstream, curl assertions
|
||||
run: ./scripts/ci-gates.sh smoke
|
||||
|
||||
# The README quotes an assertion count per gate. It used to be copied by
|
||||
# hand out of a log and it drifted (OPEN-46: 229 claimed against 356
|
||||
# printed). This step makes the README pay for the number it prints.
|
||||
- name: README assertion counts match what the gate ran
|
||||
run: ./scripts/ci-gates.sh readme-counts scripts/smoke.sh
|
||||
|
||||
image:
|
||||
name: build the image and smoke it
|
||||
runs-on: ubuntu-latest
|
||||
@@ -247,6 +257,9 @@ jobs:
|
||||
EDGE: http://${{ env.OPENWAF_EDGE_HOST }}:8080
|
||||
run: ./scripts/ci-gates.sh compose-smoke
|
||||
|
||||
- name: README assertion counts match what the gate ran
|
||||
run: ./scripts/ci-gates.sh readme-counts scripts/compose-smoke.sh
|
||||
|
||||
# The console is a page, and a page fails in ways curl cannot see: a typo in
|
||||
# the inline script, a fetch that 401s, a table that renders nothing while the
|
||||
# summary looks fine. This drives it in a real Chromium.
|
||||
@@ -384,6 +397,9 @@ jobs:
|
||||
EDGE: http://${{ env.OPENWAF_EDGE_HOST }}:8090
|
||||
run: ./scripts/ci-gates.sh console
|
||||
|
||||
- name: README assertion counts match what the gate ran
|
||||
run: ./scripts/ci-gates.sh readme-counts scripts/console-check.cjs
|
||||
|
||||
# Not an artifact upload, and that is a measurement rather than a
|
||||
# preference. Run 2370 (head 36d9338) drove the page through every
|
||||
# assertion — `console check: all assertions passed` — and the job still
|
||||
|
||||
@@ -1737,10 +1737,43 @@ honest line — were red before it, while the three that describe the consequenc
|
||||
nothing in storage) were already green. That is the whole point of the finding: the
|
||||
consequence was always observable and nothing on any surface pointed at it.
|
||||
|
||||
The compose gate proves the guard that *reads* a stored row, not only the one
|
||||
that writes it. `RedirectTarget.IsSendable` runs on the write path and again on
|
||||
every request, and the read-side half had never been seen on the shipped image —
|
||||
because the API cannot be asked to store a target it refuses, and the row that
|
||||
half exists for arrives by another route: a restored backup, a hand edit, an
|
||||
import from a release that had no guard. So the gate writes a good target through
|
||||
the API, then rewrites the stored column underneath a running edge through the
|
||||
same sidecar, and asks what the edge sends once the snapshot rebuilds. A row
|
||||
holding `javascript:alert(1)` answers 301 to the policy's default target and
|
||||
never to the stored value; a row holding a CRLF-bearing target answers 301 rather
|
||||
than the 500 Kestrel used to produce, and injects nothing. Six assertions, and
|
||||
they are the first six ever run against the deployable rather than against the
|
||||
test host.
|
||||
|
||||
It also tells a dead edge from a slow one. A curl `000` is the gate failing to
|
||||
reach the stack, and the log used to carry the number and nothing else: one Linux
|
||||
run read `000` at `geo off restores the country`, and "the edge hung" and "the
|
||||
edge died" were indistinguishable afterwards. Every `000` now samples the
|
||||
container the request was aimed at and prints what it reports, and the gate ends
|
||||
with a scene that makes the dead case happen on purpose — `compose stop edge`,
|
||||
one request, `exited/unhealthy` in the log beside the `000`, `compose start`, and
|
||||
the stack back to `running/healthy` answering 404. Five assertions.
|
||||
|
||||
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
|
||||
total that gate recorded in this run — each gate writes its total into
|
||||
`$GATE_TOTALS_DIR`, which the workflow sets per job and `all` sets for a local
|
||||
run. It exists because those numbers were copied by hand out of a log and they
|
||||
drifted: the first run of this check said the README claimed **229** assertions
|
||||
for `compose-smoke.sh` while that gate was printing **368**, a 139-assertion gap
|
||||
nothing could see. With no total recorded it exits 2 — "cannot verify" — rather
|
||||
than reporting a pass.
|
||||
|
||||
The console gate starts the stack, seeds a source sitting at 2 of a threshold of
|
||||
3 and an operator block with a reason, four 502s from an address chosen for this
|
||||
run (`/boom`, see the alerting note above), drives `/admin` in a real Chromium,
|
||||
and asserts 164 things. The read side: it authenticated, listed the streak as
|
||||
and asserts 168 things. The read side: it authenticated, listed the streak as
|
||||
current-over-threshold rather than as a historical maximum, listed the operator
|
||||
block with its reason, listed observations and countries with bars that have
|
||||
real pixel widths, said how many recorded sources the observation table is only
|
||||
@@ -1774,7 +1807,19 @@ inside any table body, and keep its own title — the path in an observation row
|
||||
is whatever an anonymous visitor asked for, and the only browser in this system
|
||||
holding the admin token is the one rendering it. Reducing `esc()` to the identity
|
||||
function makes this gate go red with 6 failures and the page title becomes
|
||||
`"XSS"`, which is the price of the invariant. Then the pass repeats at 375 px in dark
|
||||
`"XSS"`, which is the price of the invariant. Two reads in this gate are now
|
||||
waited for rather than sampled once. The observation table used to be read at one
|
||||
instant, and in an act run that instant was empty — `X-Total-Count: 0` where the
|
||||
same head a minute earlier had 11 rows — while the rows are written by the
|
||||
coalesced observation writer, so an empty table is a normal moment in a run that
|
||||
is about to be correct; the table is now polled with a stated budget and the wait
|
||||
is printed whether or not a row arrived. And the page's own request paths are
|
||||
pinned: the gate records the admin-api calls the page issues while it loads, with
|
||||
their statuses, and asserts the 14 it expects, no others, their query strings
|
||||
intact, and none answered 404. Four assertions, and the reason for them is that a
|
||||
wrong URL on a page never looks like a wrong URL — `withSrc`'s first version
|
||||
appended `&source=` to a bare path, the edge answered 404, and the page printed
|
||||
"unknown scope" for a request that never arrived. Then the pass repeats at 375 px in dark
|
||||
mode, where the document must not scroll sideways
|
||||
and the status line must clear WCAG AA (measured 11.85:1). It needs `playwright-core`
|
||||
(`PLAYWRIGHT_CORE=/path/to/it`) and exits 2 when that is missing — a gate that
|
||||
@@ -2011,6 +2056,7 @@ the run number to read it at.
|
||||
| 2365 | `63cc575` | `lint` green, `image` **348/0**, `console` down to one failure, `source` still one race |
|
||||
| 2370 | `36d9338` | `lint`, `source` (378/378, 405/405, 256/0) and `image` (348/0) green; `console` printed `console check: all assertions passed` and the job went red on `actions/upload-artifact@v4` — not supported by this runner |
|
||||
| **2376** | `992a7b7` | **all four jobs green**: `lint` (actionlint 1.7.12, shellcheck 0.11.0), `source` (unit **378/378**, integration **405/405**, smoke **256/0**), `image` (`openwaf:ci` 258 MB, compose smoke **348/0**), `console` (**164 assertions, 0 failed**, screenshots 375,961 and 405,773 bytes named with their sha256 in the log) |
|
||||
| **2405** | `249e3f9` | **all four jobs green again**: `lint` now runs `./scripts/ci-gates.sh lint` — one definition, two callers — and prints actionlint 1.7.12 and shellcheck 0.11.0; `source` unit **378/378**, integration **405/405**, smoke **256/0**; `image` `openwaf:ci` 258 MB and compose smoke **356/0** (348 plus the eight assertions OPEN-45 and OPEN-49 asked for); `console` **164 assertions, 0 failed**, screenshots 375,596 and 405,547 bytes named with their sha256 |
|
||||
|
||||
The ten red assertions 2361 reported across `image` and `console` were one
|
||||
cause, and it was in the workflow rather than in the product: the two "put the
|
||||
@@ -2145,8 +2191,8 @@ 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 229 assertions against the built image (compose + nginx)
|
||||
scripts/console-check.cjs 164 assertions against the page, in a real Chromium
|
||||
scripts/compose-smoke.sh 368 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
|
||||
.github/workflows/geo-freshness.yml the same check on a schedule
|
||||
|
||||
+62
-1
@@ -6,6 +6,9 @@
|
||||
#
|
||||
# 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 readme-counts scripts/<gate> (compares the README's
|
||||
# assertion count with what that gate printed
|
||||
# in this run; needs GATE_TOTALS_DIR)
|
||||
# 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
|
||||
@@ -134,6 +137,54 @@ lint() {
|
||||
fi
|
||||
}
|
||||
|
||||
# The README names an assertion count per gate. Those numbers were copied by
|
||||
# hand out of a log, and they drift: OPEN-46 measured the README claiming
|
||||
# scripts/compose-smoke.sh had 229 assertions while that gate was printing 356.
|
||||
# A number nobody checks is not a measurement, so this gate compares what the
|
||||
# README claims with what the gate recorded in this run. Each gate writes its own
|
||||
# total into $GATE_TOTALS_DIR when that variable is set — CI sets it once per
|
||||
# job, `all` sets it for a local run. With nothing to compare this gate exits 2
|
||||
# ("cannot verify"), because a check that reports a pass because it had no input
|
||||
# is the defect this is about.
|
||||
readme_counts() {
|
||||
local gate="${1:-}"
|
||||
banner "readme-counts $gate"
|
||||
if [ -z "$gate" ]; then
|
||||
printf 'usage: %s readme-counts scripts/<gate>\n' "$0" >&2
|
||||
return 2
|
||||
fi
|
||||
if [ ! -f README.md ]; then
|
||||
printf 'no README.md to read: cannot verify (exit 2), not a pass\n' >&2
|
||||
return 2
|
||||
fi
|
||||
local claimed
|
||||
claimed=$(awk -v g="$gate" '$1==g && $3=="assertions" { print $2; exit }' README.md)
|
||||
if [ -z "$claimed" ]; then
|
||||
printf 'README.md names no assertion count for %s: nothing to verify (exit 2)\n' "$gate" >&2
|
||||
return 2
|
||||
fi
|
||||
if [ -z "${GATE_TOTALS_DIR:-}" ]; then
|
||||
printf 'GATE_TOTALS_DIR is not set, so %s recorded no total this run: cannot verify (exit 2)\n' "$gate" >&2
|
||||
return 2
|
||||
fi
|
||||
local measured_name
|
||||
measured_name=$(printf '%s' "$gate" | tr '/' '_')
|
||||
local measured_file="$GATE_TOTALS_DIR/$measured_name.txt"
|
||||
if [ ! -f "$measured_file" ]; then
|
||||
printf '%s did not record a total in %s: cannot verify (exit 2)\n' "$gate" "$GATE_TOTALS_DIR" >&2
|
||||
return 2
|
||||
fi
|
||||
local measured failed
|
||||
read -r _ measured failed < "$measured_file"
|
||||
printf 'README claims %s assertions for %s; the gate printed %s (%s failed)\n' \
|
||||
"$claimed" "$gate" "$measured" "$failed"
|
||||
if [ "$claimed" != "$measured" ]; then
|
||||
printf 'the README is stale by %s assertions. Either the gate changed and the README did not, or the README was never measured.\n' \
|
||||
"$((measured - claimed))" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
case "${1:-all}" in
|
||||
restore) restore ;;
|
||||
build) build ;;
|
||||
@@ -144,8 +195,18 @@ case "${1:-all}" in
|
||||
compose-smoke) compose_smoke ;;
|
||||
console) console ;;
|
||||
lint) lint ;;
|
||||
readme-counts) readme_counts "${2:-}" ;;
|
||||
all)
|
||||
# Set here rather than requiring the caller: the totals only mean something
|
||||
# if the gates that produced them and the check that reads them ran in the
|
||||
# same invocation.
|
||||
export GATE_TOTALS_DIR="${GATE_TOTALS_DIR:-$(mktemp -d)}"
|
||||
restore; build; unit; integration; smoke; image; compose_smoke
|
||||
# The two gates `all` actually ran. console is not among them, so its README
|
||||
# number is verified by the console job (or by an operator who ran it and
|
||||
# then calls readme-counts with the same GATE_TOTALS_DIR).
|
||||
readme_counts scripts/smoke.sh
|
||||
readme_counts scripts/compose-smoke.sh
|
||||
printf '\nall gates passed\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'
|
||||
@@ -153,7 +214,7 @@ case "${1:-all}" in
|
||||
printf 'If a workflow or script changed, run: %s lint\n' "$0"
|
||||
;;
|
||||
*)
|
||||
printf 'usage: %s restore|build|unit|integration|smoke|image|compose-smoke|console|lint|all\n' "$0" >&2
|
||||
printf 'usage: %s restore|build|unit|integration|smoke|image|compose-smoke|console|lint|readme-counts|all\n' "$0" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
+142
-1
@@ -85,7 +85,41 @@ streaks_info() {
|
||||
"$(printf '%s' "$STREAKS_JSON" | jval trackedSources)" \
|
||||
"$(printf '%s' "$STREAKS_JSON" | jval standingStreaks)"
|
||||
}
|
||||
code() { curl -s -m 10 -o /dev/null -w '%{http_code}' "$@"; }
|
||||
# OPEN-39: curl's 000 is not an answer from the edge, it is the gate failing to
|
||||
# reach it — and the gate used to print it as if it were a product answer.
|
||||
# Measured on Linux: `geo off restores the country` read 000 once and the log
|
||||
# said nothing about whether the container had died or was merely slow. Those are
|
||||
# different news and they lead to different fixes, so every 000 now samples the
|
||||
# container the request was aimed at and prints what it found. On stderr, so the
|
||||
# diagnosis cannot leak into the value an assertion is comparing.
|
||||
DEAD_LOG=$(mktemp "${TMPDIR:-/tmp}/openwaf-dead-codes.XXXXXX")
|
||||
edge_state() {
|
||||
local cid
|
||||
# -a, not the default: `compose ps` hides a stopped service, and "the container
|
||||
# is not in the listing" is the wrong thing to print about an edge that exists
|
||||
# and has exited — naming that difference is the whole reason this helper
|
||||
# exists (OPEN-39).
|
||||
cid=$(docker compose ps -aq edge 2>/dev/null)
|
||||
if [ -z "$cid" ]; then printf 'no-container'; return; fi
|
||||
printf '%s/%s' \
|
||||
"$(docker inspect -f '{{.State.Status}}' "$cid" 2>/dev/null)" \
|
||||
"$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}no-healthcheck{{end}}' "$cid" 2>/dev/null)"
|
||||
}
|
||||
code() {
|
||||
local http_code
|
||||
http_code=$(curl -s -m 10 -o /dev/null -w '%{http_code}' "$@")
|
||||
if [ "$http_code" = 000 ]; then
|
||||
# A file, not a shell variable: every caller reaches this through
|
||||
# `$(code …)`, which is a subshell, so a counter incremented here is gone
|
||||
# before the assertion that wants to read it. Measured in the first run of
|
||||
# this scene: the diagnosis printed, the count stayed zero, and the count's
|
||||
# assertion went red on the line directly under the proof it worked.
|
||||
printf '000\t%s\n' "$*" >> "$DEAD_LOG"
|
||||
printf ' info curl answered 000 for %s; the edge container reports %s\n' "$*" "$(edge_state)" >&2
|
||||
fi
|
||||
printf '%s' "$http_code"
|
||||
}
|
||||
dead_codes() { wc -l < "$DEAD_LOG" | tr -d ' '; }
|
||||
hdr() { curl -s -m 10 -D - -o /dev/null "$@" | tr -d '\r'; }
|
||||
xff() { printf 'X-Forwarded-For: %s' "$1"; }
|
||||
# One scalar field out of a JSON object, for the endpoints that answer with an
|
||||
@@ -124,6 +158,7 @@ cleanup() {
|
||||
-d '{"mode":"Enforce","geo":"Off","streakThreshold":10,"trustProxyHeaders":false}' "$EDGE/admin-api/policy" >/dev/null
|
||||
admin -X DELETE "$EDGE/admin-api/blocks?source=engine" >/dev/null
|
||||
[ "${KEEP_UP:-0}" = 1 ] || docker compose down >/dev/null 2>&1
|
||||
rm -f "$DEAD_LOG"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@@ -2104,6 +2139,112 @@ check 'the shipped read-only token previews, no token does not' '200 401' \
|
||||
$(code "$EDGE/admin-api/impact?match=$IMP_NET_Q")"
|
||||
|
||||
|
||||
echo '- a redirect target that arrived by a route the API refuses is still never sent'
|
||||
# OPEN-40. The write-side guard is proven above. The read-side guard — the one
|
||||
# that re-checks RedirectTarget.IsSendable on every request, in
|
||||
# DecisionEngine.BlockResponse — had never been shown on the shipped image,
|
||||
# because the API cannot be asked to store a target it refuses, and no other
|
||||
# route writes one. The row that guard exists for is a row that got there another
|
||||
# way: a restored backup, a hand edit, an import from a release that had no
|
||||
# guard. So the gate writes a good row through the API, rewrites the stored
|
||||
# column underneath a running edge, and asks what the edge sends now.
|
||||
BADRED_SRC=203.0.113.248
|
||||
BADRED_NET_SRC=203.0.113.249
|
||||
for S in $BADRED_SRC $BADRED_NET_SRC; do
|
||||
admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$S\",\"reason\":\"good target\",\"redirectTo\":\"https://honeypot.example.org/good\"}" \
|
||||
"$EDGE/admin-api/blocks" >/dev/null
|
||||
done
|
||||
check 'a sendable target is sent while it is sendable' 'https://honeypot.example.org/good' \
|
||||
"$(hdr -H "$(xff "$BADRED_SRC")" "$EDGE/any/path" | sed -n 's/^[Ll]ocation: //p')"
|
||||
EDGE_CID=$(docker compose ps -q edge)
|
||||
# The column is looked up in the schema rather than typed here: this scene is
|
||||
# about the value, and a scene that goes red because a column was renamed stops
|
||||
# proving anything about the guard.
|
||||
sidecar <<PYSQL
|
||||
import sqlite3
|
||||
c = sqlite3.connect("/app/data/openwaf.db", isolation_level=None)
|
||||
cols = [r[1] for r in c.execute("PRAGMA table_info(block_entries)")]
|
||||
col = next(n for n in cols if n.lower() == "redirectto")
|
||||
for src, val in (("$BADRED_SRC", "javascript:alert(1)"),
|
||||
("$BADRED_NET_SRC", "http://x.invalid/\\r\\nX-Injected: 1")):
|
||||
n = c.execute("UPDATE block_entries SET %s = ? WHERE SourceKey = ?" % col, (val, src)).rowcount
|
||||
print(" info rewrote %s stored row(s) for %s to %r" % (n, src, val))
|
||||
PYSQL
|
||||
# The guard reads the snapshot, and the snapshot is rebuilt on the TTL, so the
|
||||
# rewritten row has to be allowed to arrive before it can be judged.
|
||||
BADRED_CODE=''
|
||||
BADRED_LOC=''
|
||||
for _ in $(seq 1 14); do
|
||||
BADRED_HDR=$(hdr -H "$(xff "$BADRED_SRC")" "$EDGE/any/path")
|
||||
BADRED_CODE=$(printf '%s' "$BADRED_HDR" | sed -n 's|^HTTP/[0-9.]* \([0-9]\{3\}\).*|\1|p')
|
||||
BADRED_LOC=$(printf '%s' "$BADRED_HDR" | sed -n 's/^[Ll]ocation: //p')
|
||||
[ "$BADRED_LOC" != "https://honeypot.example.org/good" ] && break
|
||||
sleep 3
|
||||
done
|
||||
printf ' info with a javascript: target in the stored row: %s, Location %s\n' \
|
||||
"${BADRED_CODE:-none}" "${BADRED_LOC:-none}"
|
||||
# Not inside $( ): a case pattern ending in `*)` closes an enclosing command
|
||||
# substitution, so the first version of this assertion compared the literal text
|
||||
# `echo no ;; *) echo yes ;; esac)` and went red about a Location that was fine.
|
||||
# The same trap this file already names for the CRLF refusal above it.
|
||||
BADRED_LEAKS=no
|
||||
case "$BADRED_LOC" in
|
||||
*javascript:*) BADRED_LEAKS=yes ;;
|
||||
esac
|
||||
check 'the stored javascript: target is never sent as a Location' 'no' "$BADRED_LEAKS"
|
||||
check 'and the request is still a block, not a server error' '301' "$BADRED_CODE"
|
||||
check 'and it falls back to the policy default target' 'https://www.iana.org/help/example-domains' \
|
||||
"$BADRED_LOC"
|
||||
BADRED2_HDR=$(hdr -H "$(xff "$BADRED_NET_SRC")" "$EDGE/any/path")
|
||||
BADRED2_CODE=$(printf '%s' "$BADRED2_HDR" | sed -n 's|^HTTP/[0-9.]* \([0-9]\{3\}\).*|\1|p')
|
||||
printf ' info with a CRLF-bearing target in the stored row: %s\n' "${BADRED2_CODE:-none}"
|
||||
check 'a stored CRLF target does not turn the block into a 500' '301' "$BADRED2_CODE"
|
||||
check 'and it injects no header on the way out' 'yes' \
|
||||
"$(printf '%s' "$BADRED2_HDR" | grep -qi 'X-Injected' && echo no || echo yes)"
|
||||
for S in $BADRED_SRC $BADRED_NET_SRC; do
|
||||
admin -X DELETE "$EDGE/admin-api/blocks?source=operator&key=$S" >/dev/null
|
||||
done
|
||||
check 'the scene leaves no block behind' '404 404' \
|
||||
"$(code -H "$(xff "$BADRED_SRC")" "$EDGE/any/path") $(code -H "$(xff "$BADRED_NET_SRC")" "$EDGE/any/path")"
|
||||
|
||||
echo '- the gate tells a dead edge from a slow one'
|
||||
# OPEN-39. A 000 from curl is the gate failing to reach the edge, and until now
|
||||
# the log carried the number and nothing else, so "the edge hung" and "the edge
|
||||
# died" produced the same red line. The helper now samples the container with
|
||||
# every 000; this proves the distinction end to end by making the dead case
|
||||
# happen on purpose, which is the only way to show the diagnosis names it.
|
||||
DEAD_CODES_BEFORE=$(dead_codes)
|
||||
docker compose stop edge >/dev/null 2>&1
|
||||
DEAD_CODE=$(code "$EDGE/any/path")
|
||||
DEAD_STATE=$(edge_state)
|
||||
printf ' info with the container stopped: curl answered %s and the container reports %s\n' \
|
||||
"$DEAD_CODE" "$DEAD_STATE"
|
||||
check 'a stopped edge answers no http code at all' '000' "$DEAD_CODE"
|
||||
check 'and the gate names the container state that goes with it' 'exited' \
|
||||
"$(printf '%s' "$DEAD_STATE" | cut -d/ -f1)"
|
||||
check 'and the 000 was counted as an unreachable answer' 'yes' \
|
||||
"$([ "$(dead_codes)" -gt "$DEAD_CODES_BEFORE" ] && echo yes || echo no)"
|
||||
docker compose start edge >/dev/null 2>&1
|
||||
ALIVE_STATE='none'
|
||||
for _ in $(seq 1 90); do
|
||||
ALIVE_STATE=$(edge_state)
|
||||
[ "$ALIVE_STATE" = "running/healthy" ] && break
|
||||
sleep 1
|
||||
done
|
||||
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 total is printed for the reader, and written where
|
||||
# scripts/ci-gates.sh readme-counts can compare it with the number the README
|
||||
# claims for this gate (OPEN-46: the README said 229 while this file was
|
||||
# printing 356, and nothing anywhere could tell).
|
||||
if [ -n "${GATE_TOTALS_DIR:-}" ]; then
|
||||
mkdir -p "$GATE_TOTALS_DIR"
|
||||
printf 'scripts/compose-smoke.sh %d %d\n' "$PASS" "$FAIL" > "$GATE_TOTALS_DIR/scripts_compose-smoke.sh.txt"
|
||||
fi
|
||||
echo
|
||||
printf 'compose smoke: %d passed, %d failed\n' "$PASS" "$FAIL"
|
||||
[ "$FAIL" -eq 0 ]
|
||||
|
||||
+120
-3
@@ -45,11 +45,31 @@ try {
|
||||
// assertion after the token click died. Best-effort picture on the way out — a
|
||||
// screenshot failure must not mask the real error.
|
||||
const failures = [];
|
||||
let assertionsRun = 0;
|
||||
const check = (name, ok, detail) => {
|
||||
assertionsRun += 1;
|
||||
console.log(` ${ok ? 'ok ' : 'FAIL'} ${name}${detail ? ' — ' + detail : ''}`);
|
||||
if (!ok) failures.push(name);
|
||||
};
|
||||
|
||||
// The number this gate asserts is quoted in the README, and until now the only
|
||||
// way to get it was to count `ok` lines in a log by hand — which is how the
|
||||
// README came to claim 229 assertions for a compose gate printing 356 (OPEN-46).
|
||||
// So the gate states its own total, and when GATE_TOTALS_DIR is set (CI sets it
|
||||
// per job; scripts/ci-gates.sh all sets it for a local run) it writes it where
|
||||
// scripts/ci-gates.sh readme-counts can compare it with what the README claims.
|
||||
const recordTotal = () => {
|
||||
const dir = process.env.GATE_TOTALS_DIR;
|
||||
if (!dir) return;
|
||||
try {
|
||||
require('fs').mkdirSync(dir, { recursive: true });
|
||||
require('fs').writeFileSync(`${dir}/scripts_console-check.cjs.txt`,
|
||||
`scripts/console-check.cjs ${assertionsRun} ${failures.length}\n`);
|
||||
} catch (e) {
|
||||
console.error(' (could not record the gate total: ' + e.message + ')');
|
||||
}
|
||||
};
|
||||
|
||||
// WCAG relative luminance, so the assertion is a number and not an opinion.
|
||||
const luminance = ([r, g, b]) => {
|
||||
const f = (c) => { c /= 255; return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4); };
|
||||
@@ -68,6 +88,38 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
page.on('pageerror', (e) => jsProblems.push('pageerror: ' + e.message));
|
||||
page.on('console', (m) => { if (m.type() === 'error') jsProblems.push('console.error: ' + m.text()); });
|
||||
|
||||
// OPEN-37: nothing pinned the paths this page asks for. A wrong URL on a page
|
||||
// never looks like a wrong URL — it looks like an empty table, or like the
|
||||
// sentence "NOT READ" in a note, and the assertion that catches it quotes the
|
||||
// page's prose instead of naming the call that failed. That is not a
|
||||
// hypothetical here: withSrc's first version appended "&source=" to a bare
|
||||
// path, the edge answered 404, and the page printed "unknown scope" for a
|
||||
// request that never arrived. So the gate records the admin-api calls the page
|
||||
// makes while it loads, with their status, and pins the set below.
|
||||
const apiCalls = new Map(); // path+search -> how many times the page asked
|
||||
const apiStatus = new Map(); // path+search -> the statuses it was answered
|
||||
let recordingReads = false;
|
||||
const apiPathOf = (url) => {
|
||||
try {
|
||||
const u = new URL(url);
|
||||
return u.pathname.startsWith('/admin-api/') ? u.pathname + (u.search || '') : null;
|
||||
} catch (e) { return null; }
|
||||
};
|
||||
page.on('request', (req) => {
|
||||
if (!recordingReads) return;
|
||||
const key = apiPathOf(req.url());
|
||||
if (key) apiCalls.set(key, (apiCalls.get(key) || 0) + 1);
|
||||
});
|
||||
page.on('response', (res) => {
|
||||
if (!recordingReads) return;
|
||||
const key = apiPathOf(res.url());
|
||||
if (!key) return;
|
||||
const seen = apiStatus.get(key) || new Set();
|
||||
seen.add(res.status());
|
||||
apiStatus.set(key, seen);
|
||||
});
|
||||
|
||||
recordingReads = true;
|
||||
await page.goto(`${EDGE}/admin`, { waitUntil: 'domcontentloaded' });
|
||||
await page.fill('#token', TOKEN);
|
||||
await page.click('#save');
|
||||
@@ -105,7 +157,26 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
};
|
||||
const streakRows = await cells('#streaks tbody tr');
|
||||
const blockRows = await cells('#blocks tbody tr');
|
||||
const obsRows = await page.$$eval('#obs tbody tr', (r) => r.length);
|
||||
// OPEN-43: in an act run this read the table once and it was empty —
|
||||
// `X-Total-Count: 0` where the same head a minute earlier had 11 rows. The
|
||||
// rows are written by the coalesced observation writer (flush every 15 s, at
|
||||
// most one durable write per source per 30 s), so an empty table is a normal
|
||||
// instant in a run that is about to be correct, and a single read cannot tell
|
||||
// that from "the observation pillar is not writing". The seed already waits
|
||||
// 35 s for exactly this reason; the gate reading the table once undid it. So
|
||||
// the table is waited for with a stated budget, and the wait is printed
|
||||
// whether or not a row arrived — `waited 20000 ms, 0 rows` is a different
|
||||
// sentence from `read 0 rows at the first look`, and it is the honest one.
|
||||
let obsRows = 0;
|
||||
const obsLoadStart = Date.now();
|
||||
const OBS_LOAD_BUDGET_MS = 20000;
|
||||
for (;;) {
|
||||
obsRows = await page.$$eval('#obs tbody tr', (r) => r.length);
|
||||
if (obsRows > 0) break;
|
||||
if (Date.now() - obsLoadStart >= OBS_LOAD_BUDGET_MS) break;
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
}
|
||||
console.log(` info the observation table was waited ${Date.now() - obsLoadStart} ms to hold a row`);
|
||||
const countryRows = await page.$$eval('#countries tbody tr', (r) => r.length);
|
||||
const html = await page.content();
|
||||
if (SCREENSHOT) await page.screenshot({ path: SCREENSHOT, fullPage: true });
|
||||
@@ -302,6 +373,50 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
blockRows.some((r) => r[0] === SEED_MARKUP_BLOCK && /<svg onload=/.test(r[2] || '')),
|
||||
JSON.stringify(blockRows.map((r) => [r[0], r[2]])));
|
||||
}
|
||||
// The load window is over: everything after this point is a write the gate
|
||||
// itself performs, and those calls belong to the gate, not to the page.
|
||||
recordingReads = false;
|
||||
const READ_CALLS = [
|
||||
'/admin-api/state',
|
||||
'/admin-api/blocks?live=false',
|
||||
'/admin-api/observations?limit=25',
|
||||
'/admin-api/streaks',
|
||||
'/admin-api/countries/summary',
|
||||
'/admin-api/countries',
|
||||
'/admin-api/allow?live=false&limit=500',
|
||||
'/admin-api/rules?live=false&limit=500',
|
||||
'/admin-api/rate?limit=25',
|
||||
'/admin-api/rate-rules?live=false&limit=500',
|
||||
'/admin-api/alerts?limit=25',
|
||||
'/admin-api/geo',
|
||||
'/admin-api/changes?limit=25',
|
||||
'/admin-api/netblocks',
|
||||
];
|
||||
const seenCalls = [...apiCalls.keys()].sort();
|
||||
const missingCalls = READ_CALLS.filter((c) => !apiCalls.has(c));
|
||||
const unexpectedCalls = seenCalls.filter((c) => !READ_CALLS.includes(c));
|
||||
const notFound = [...apiStatus.entries()].filter(([, st]) => st.has(404)).map(([k]) => k);
|
||||
console.log(` info the page asked for ${seenCalls.length} distinct admin-api calls while loading: `
|
||||
+ JSON.stringify(seenCalls));
|
||||
check('the page asks for every read its tables need, by the path the edge publishes',
|
||||
missingCalls.length === 0,
|
||||
`missing ${JSON.stringify(missingCalls)} of the ${READ_CALLS.length} the page issues`);
|
||||
check('and it asks for nothing the edge does not publish',
|
||||
unexpectedCalls.length === 0, `unexpected ${JSON.stringify(unexpectedCalls)}`);
|
||||
// The query strings are part of the path the page depends on: `?live=false` is
|
||||
// what makes an expired exemption row appear at all, and `?limit=25` is what
|
||||
// the "newest N of M" note is measured against. A refresh that drops one is a
|
||||
// different page wearing the same markup, so the pinned call list above is
|
||||
// checked with its query string, not just its route.
|
||||
check('the capped and liveness-filtered reads ask with their query string intact',
|
||||
apiCalls.has('/admin-api/allow?live=false&limit=500')
|
||||
&& apiCalls.has('/admin-api/rules?live=false&limit=500')
|
||||
&& apiCalls.has('/admin-api/observations?limit=25')
|
||||
&& apiCalls.has('/admin-api/alerts?limit=25'),
|
||||
JSON.stringify(seenCalls.filter((c) => c.indexOf('?') !== -1)));
|
||||
check('no read the page issued was answered 404',
|
||||
notFound.length === 0, `404 for ${JSON.stringify(notFound)}`);
|
||||
|
||||
check('the page threw no javascript', jsProblems.length === 0, jsProblems.join(' | '));
|
||||
|
||||
// The read side of the page is one thing; the write side is the part that can
|
||||
@@ -1912,12 +2027,14 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
await page.screenshot({ path: SCREENSHOT.replace(/(\.[a-z0-9]+)$/i, '.failure$1'), fullPage: true });
|
||||
} catch (e) { console.error(' (no failure screenshot: ' + e.message + ')'); }
|
||||
}
|
||||
console.error(`console check: ${failures.length} assertion(s) failed`);
|
||||
recordTotal();
|
||||
console.error(`console check: ${assertionsRun} assertions, ${failures.length} failed`);
|
||||
await browser.close();
|
||||
process.exit(1);
|
||||
}
|
||||
recordTotal();
|
||||
await browser.close();
|
||||
console.log('console check: all assertions passed');
|
||||
console.log(`console check: ${assertionsRun} assertions, 0 failed — all assertions passed`);
|
||||
})().catch(async (e) => {
|
||||
console.error('console check failed to run:', e.message);
|
||||
if (SCREENSHOT) {
|
||||
|
||||
@@ -1452,6 +1452,12 @@ check 'switching the engine off is accepted' Off \
|
||||
echo '- healthcheck mode (a shell-less image can only ask the binary)'
|
||||
dotnet "$BIN" --healthcheck; check 'healthcheck exit code' 0 "$?"
|
||||
|
||||
# The total, for the reader and for scripts/ci-gates.sh readme-counts, which
|
||||
# compares it with the number the README claims for this gate (OPEN-46).
|
||||
if [ -n "${GATE_TOTALS_DIR:-}" ]; then
|
||||
mkdir -p "$GATE_TOTALS_DIR"
|
||||
printf 'scripts/smoke.sh %d %d\n' "$pass" "$fail" > "$GATE_TOTALS_DIR/scripts_smoke.sh.txt"
|
||||
fi
|
||||
echo
|
||||
echo "passed $pass, failed $fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
|
||||
Reference in New Issue
Block a user