The Dockerfile pins `ARG DBIP_VERSION=YYYY-MM`, and moving that pin was a habit
someone kept by hand: 2026-10 on 2026-10-01, 2026-09 the month before that. The
runtime answer was not better. `/healthz`'s `geoStale` is a 90-day alarm, and a
month behind is not 90 days. Measured on this tree: a container whose named
volume held `dbip-country-lite-2026-09` while the Dockerfile asked for `2026-10`
reported `geoBuiltAt: 2026-09-01T01:32:45+00:00` and `geoStale: false` — and
every geo assertion in `compose-smoke.sh` stayed green, the country deny list
still refusing 8.8.8.8 with 451. The policy was being enforced on a database
nobody chose, reported as healthy.
Three pieces:
- `scripts/geo-db-freshness.sh` compares the pin with the newest release the
vendor actually serves (14 HEAD probes, newest first). Three exit codes, not
two: 0 current, 1 the vendor has something newer, 2 could not tell — no
network, or a pin the vendor has never served, which would make the image
build fail on a 404. `MACHINE=1` prints one line for the bump script.
- `scripts/geo-db-bump.sh` rewrites the ARG and prints the two commands that
make the new database actually land. It refuses to write anything when the
check could not run: a pin moved on the strength of a check that did not run
is worse than a pin left alone.
- `.github/workflows/geo-freshness.yml` runs the check on the 1st and the 8th
(dbip publishes on the 1st; the second date catches a late publish or one
failed run). It deliberately does not open a PR — a bot that cannot run the
geo assertions bumping a data dependency is a worse default than a red job.
`scripts/compose-smoke.sh` grew the assertion that ties the pin to the running
container: `the loaded geo database is the pinned one`. Its teeth were checked,
not assumed — the stale volume above produced exactly one failure:
FAIL the loaded geo database is the pinned one Dockerfile pins 2026-10, the container loaded 2026-09
a named volume is seeded once: docker volume rm openwaf_openwaf-geoip
compose smoke: 27 passed, 1 failed
and after `docker volume rm`, **28 passed, 0 failed**.
Numbers on this tree. Host, `scripts/ci-gates.sh all`, EXIT=0: build 0 warnings,
unit 54/54, integration 28/28, smoke 19/19, image 261 MB, compose-smoke 28/28.
Linux rehearsal (third run today), EXIT=0: source PASS (54/54, 28/28, 19/19),
compose 28/28 with enforcement lag 36 ms, console 26/26. The freshness script
itself in `mcr.microsoft.com/dotnet/sdk:10.0`: current pin exits 0, a forced
`PIN=2026-05` exits 1 with the bump command. actionlint 1.7.12 over both
workflow files: 0 problems; shellcheck and `bash -n` clean.
Honest edges. The scheduled job has never run, because the repository has no
remote; and GitHub disables schedules on a repository with no push for 60 days,
so a cron is a nudge with a failure mode. A red freshness job can mean "no
network" rather than "stale" — the message names which, and exit 2 is not exit 0.
76 lines
3.4 KiB
Bash
Executable File
76 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# One file says what each gate *is*, so "what CI runs" and "what an operator ran
|
|
# before pushing" stop being two different claims. CI calls one gate per step, so
|
|
# the job log still names the gate that failed; `all` runs them in order and
|
|
# stops at the first failure.
|
|
#
|
|
# 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`)
|
|
#
|
|
# 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
|
|
# putting it behind `all` would make the offline claim below false. It has its own
|
|
# scheduled job (.github/workflows/geo-freshness.yml).
|
|
#
|
|
# OPENWAF_ADMIN_TOKEN defaults below to the same throwaway CI uses; set it to
|
|
# override. Nothing here talks to anything outside the run.
|
|
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# The compose gate needs an admin token for the stack it starts. It is not a
|
|
# secret — that stack exists only inside this run and is torn down on exit — but
|
|
# requiring it meant `ci-gates.sh all` stopped at the last gate for anyone who
|
|
# forgot to export one, which made the one-command entry point a lie. Same value
|
|
# CI uses, overridable by the caller.
|
|
export OPENWAF_ADMIN_TOKEN="${OPENWAF_ADMIN_TOKEN:-ci-only-throwaway}"
|
|
|
|
banner() { printf '\n\033[1m=== gate: %s ===\033[0m\n' "$1"; }
|
|
|
|
restore() { banner restore; dotnet restore dotnet/OpenWaf.slnx; }
|
|
|
|
# TreatWarningsAsErrors is set in Directory.Build.props, so this is also the
|
|
# warning gate.
|
|
build() { banner build; dotnet build dotnet/OpenWaf.slnx -c Release --no-restore; }
|
|
|
|
unit() { banner unit; dotnet test dotnet/OpenWaf.Tests.Unit/OpenWaf.Tests.Unit.csproj -c Release --no-build; }
|
|
|
|
integration() { banner integration; dotnet test dotnet/OpenWaf.Tests.Integration/OpenWaf.Tests.Integration.csproj -c Release --no-build; }
|
|
|
|
smoke() { banner smoke; ./scripts/smoke.sh; }
|
|
|
|
# The plain build the README shows, plus its size: the compose path would hide a
|
|
# Dockerfile regression that this step catches.
|
|
image() { banner image; docker build -t openwaf:ci .; docker image ls openwaf:ci --format '{{.Repository}}:{{.Tag}} {{.Size}}'; }
|
|
|
|
compose_smoke() { banner compose-smoke; ./scripts/compose-smoke.sh; }
|
|
|
|
# The browser gate over the operator page. It is a gate, so it lives here too and
|
|
# CI calls it by the same name. It is NOT part of `all`: it needs a real
|
|
# Chromium, and a machine without one exits 2 ("cannot run"), which is a
|
|
# different answer from 1 ("the page is wrong") and would otherwise make the
|
|
# one-command entry point unrunnable. Run it explicitly before pushing a change
|
|
# to the console.
|
|
console() { banner console; ./scripts/console-smoke.sh; }
|
|
|
|
case "${1:-all}" in
|
|
restore) restore ;;
|
|
build) build ;;
|
|
unit) unit ;;
|
|
integration) integration ;;
|
|
smoke) smoke ;;
|
|
image) image ;;
|
|
compose-smoke) compose_smoke ;;
|
|
console) console ;;
|
|
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 'If the console changed, run: %s console\n' "$0"
|
|
;;
|
|
*)
|
|
printf 'usage: %s restore|build|unit|integration|smoke|image|compose-smoke|console|all\n' "$0" >&2
|
|
exit 2
|
|
;;
|
|
esac
|