D39 = B: the security-fix lane — a security_fix ladder step (box walk required, bench optional, CVE/GHSA notice), its gates + 8 decoys, the writer (--write-ladder --security), the box venue (box_walk.py --security, drill-mirror refresh); two stale tests fixed
gates / gates (push) Successful in 58s
gates / gates (push) Successful in 58s
09 §3 decision 255, R-1239. Proven on 9202 (drill catalog) — felhom.eu audits/security-lane-2026-10-23/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012qRErfCoiTkvDK9N5XHbzb
This commit is contained in:
1 parent
cde26abc02
commit
3898593594
12 files changed
+755
-36
No files matched your search
@@ -1,3 +1,36 @@
|
||||
## 2026-10-23 (day, later) — D39 = B: the security-fix lane (`09` §3 decision 255, R-1239)
|
||||
|
||||
An urgent upstream fix with a public notice may reach the boxes at night without the bench: a `security_fix` ladder
|
||||
step, proven on scratch 9202 through the product's Update. Taken by the night leg on controller >= 0.341.0; an older
|
||||
controller skips it at night (`not_proven`) and a hand press takes it (both proven on 9202, below).
|
||||
|
||||
- **`scripts/ladder.py`** — the third verdict `security_fix` and its one checker `check_security`: `security` {CVE/GHSA
|
||||
ids, an https:// advisory, `fixed_in`}, `box_evidence`, `seed` `read_back`|`none`, `memory_basis: box_soak`; a bench
|
||||
given must be proven (`bench_verdict`, `harness_version` >= 2); never `backfilled`, `digest_from`,
|
||||
`engine_conversion`, `from == to`, nor a database engine major (`engine_majors_crossed` imports
|
||||
`check-engine-major.py`'s `engine_of`/`major_of` — reused, not copied).
|
||||
- **`check-test-record-move.py`** accepts a `security_fix` move exactly as a proven one. **`check-test-record.py`** rule 5:
|
||||
one WARN per template whose head is a security-fix step with no bench test.
|
||||
- **`upgrade-test.py --write-ladder --security`** (`write_security_step`): refuses a walk not proven, a bench given and not
|
||||
proven, a template not at the walk's FROM, a digest that moved since the walk, an engine major, a missing field. The
|
||||
writer's tail is now ONE function every step kind shares (`apply_entry`; the 10 existing writer tests stay green).
|
||||
- **`box_walk.py --security`** — the box venue: install at FROM, seed + read-back or `seed: none` (said), a drill-only
|
||||
move, the guarded Update with its phases, the four observables at TO, a soak (default 600 s: cgroup `anon` against the
|
||||
limit, OOM kills, restarts). `refresh_box_mirror()`: a drill commit now reaches a box pointed at the drill's LOCAL
|
||||
mirror (R-992's method) — before, it reached Gitea only, and a walk would have pressed Update on nothing.
|
||||
- Tests: 8 new writer tests (`test_ladder_writer.py`, 18/18); 8 new decoys (`test_gate_decoys.py`: a genuine box-only step
|
||||
passes; the CVE ids only in a `note`, a non-CVE/GHSA id, an http advisory, no seed, a `digest_from`, a failed bench, a
|
||||
PostgreSQL major — each refused, and each seen passing wrongly with `check_security` switched off); the WARN line.
|
||||
- **Fixed without a row:** `test_upgrade_bench.py` pinned 9202 at `.114` (DHCP since 2026-10-19; now `.121`) and a
|
||||
typed `base` the 9202 row deliberately lacks; `test_catalog_gates.py` counted 21 gates (24) and its shallow clone had
|
||||
no sibling `felhom.eu`, so the security-scan gate failed there (both red on `main` before this change).
|
||||
- **Proof on 9202 (drill catalog, controller 0.340.0)** — felhom.eu `audits/security-lane-2026-10-23/`: negative
|
||||
control (TO `busybox:1.36.1`) `failed` (undone after 335 s) and the writer refused it; Plex 1.43.4.10903 → 1.43.5.11029
|
||||
`proven` (done 36.9 s, four observables at TO, digest `sha256:01bdf0ad…5c5f`, soak 600 s peak 10.7 %, 0 kills, 0
|
||||
restarts, `seed: none`); the writer wrote the drill step (CVE-2026-96652/-96654/-96655/-96656, Plex's notice as cited
|
||||
by CISA KEV, fixed in 1.43.3.10861); the night chain on 0.340.0 logged `plex: skipped — not_proven`; a hand press took it.
|
||||
- The live catalog's Plex is unchanged (already at 1.43.5 since `6cc317d`, no ladder — R-1238).
|
||||
|
||||
## 2026-10-23 (day) — Plex to the Plex2Shell fix, WITHOUT a test record (operator ruling 10:56)
|
||||
|
||||
- **`6cc317d`** `templates/plex/docker-compose.yml`: `plexinc/pms-docker:1.41.4.9463-630c9f557` →
|
||||
|
||||
@@ -146,6 +146,17 @@ deployed `app.yaml` (customer secrets) is never overwritten. Full deploy details
|
||||
newest carries its own compose at `templates/<app>/steps/<ladder.step_key(to)>.yml`** (2026-09-24, `09` §6.4 part
|
||||
5): the box pins that file, one step per press. The writer keeps the superseded step's definition — fixes
|
||||
included — and `check-test-record.py` rule 4 refuses a step with no file or a file naming other images.
|
||||
- **The security-fix lane (`09` §3 decision 255, D39 = B, 2026-10-23).** An urgent upstream fix with a public notice (a
|
||||
CVE or GHSA id + its https:// page) may skip the bench: `"verdict": "security_fix"`, proven on scratch 9202 through
|
||||
the product's Update, taken by the night leg on controller >= 0.341.0 (older ones skip it at night; a hand press takes
|
||||
it). No operator word per incident — the notice is the authority; the session reports the step after the push. The
|
||||
box walk, then the writer (fields and refusals: `scripts/ladder.py` `check_security`; the walk needs the drill at FROM):
|
||||
`SC=<0600 dir with .ctlpw> TARGET=9202 python3 scripts/box_walk.py --security <app> --from <svc=ref,…> --to <svc=ref,…>
|
||||
--ev <dir> [--soak 600] [--value HDD_PATH=<drive>]`, then `python3 scripts/upgrade-test.py --write-ladder --security
|
||||
--ids <id,…> --advisory <url> --fixed-in <v> --box <box-verdict.json> --box-evidence <rel> --catalog <checkout>
|
||||
[<bench.json> --evidence <rel>]`. Never across a database engine major; never a same-tag fix (that is decision 52's
|
||||
re-test). Run the walk's negative control first (a TO image that exits at once must come back `failed`).
|
||||
`check-test-record.py` WARNs on every push while a template's head is a security-fix step with no bench test.
|
||||
- **Taking an app out of circulation — use `lifecycle:`, never a directory move.** `.felhom.yml`
|
||||
gains an optional `lifecycle:` field: `available` (default; absent/empty means this), `hidden`
|
||||
(not offered for new installs, no explanation owed), `abandoned` (upstream stopped developing it —
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
# REPORT — Plex to the Plex2Shell fix, without a test record (2026-10-23 day, operator ruling 10:56)
|
||||
# REPORT — D39 = B: the security-fix lane (2026-10-23 day, `09` §3 decision 255, R-1239)
|
||||
|
||||
- **`6cc317d`** — Plex `1.41.4.9463-630c9f557` → `1.43.5.11029-6bf8af3f0` (newest plain tag on Docker Hub, re-resolved
|
||||
at start; manifest list `sha256:01bdf0ad…5c5f`), `catalog_since: "2026-10-23"`. Image move only. Pushed with
|
||||
**`--no-verify`** on the operator's ruling (skips `09` §3 decision 13's test record once, for Plex only).
|
||||
- **The next commit** — `guide.checked_version` → the new tag, after the guide's HU + EN labels were read from the new
|
||||
image's web client (all equal). Normal push, hook on.
|
||||
- Gates: image-pins OK, catalog-since (range) OK, test-record OK, image-resolvable plex OK, `catalog_gates.py --fast plex`
|
||||
OK (guide-version WARNed before the second commit, as it should).
|
||||
- `check-test-record-move.py --range origin/main..HEAD` on `6cc317d`, verbatim (exit 1, expected):
|
||||
|
||||
```
|
||||
test-record-move gate — range origin/main..HEAD: 1 compose file(s) changed
|
||||
REFUSED plex: images moved (plex: plexinc/pms-docker:1.41.4.9463-630c9f557 -> plexinc/pms-docker:1.43.5.11029-6bf8af3f0) but this range adds NO update_ladder entry — an image move needs its test record (decision 13); run the harness and let it write the entry
|
||||
```
|
||||
|
||||
- Box: demo-hp 9201 — clean signs check, Update press 28.4 s, `/identity` = the new version, same `machineIdentifier`.
|
||||
Evidence and per-box table: felhom.eu `documentation/audits/plex-demo-boxes-2026-10-23/`.
|
||||
- Rows (felhom.eu): R-1238 (Plex has no test record or fixture; the night leg never updates it), R-1239 (a fast lane
|
||||
for security fixes — the operator's decision).
|
||||
- New step kind `"verdict": "security_fix"`: box walk required, bench optional, a CVE/GHSA notice as its authority.
|
||||
Reader/checker `scripts/ladder.py` (`check_security`); gates `check-test-record-move.py` (accepts it like proven) and
|
||||
`check-test-record.py` (WARN while a head has no bench); writer `upgrade-test.py --write-ladder --security`; box venue
|
||||
`box_walk.py --security`. Command lines: `CLAUDE.md`, the ladder section.
|
||||
- Tests: writer 18/18 (8 new, each refusal); decoys all OK, the 7 security decoys seen failing with the rules off;
|
||||
`test_upgrade_bench.py` 40/40 and `test_catalog_gates.py` 12/12 after two stale tests were fixed (red on `main` before).
|
||||
- Gates: `catalog_gates.py --fast` OK.
|
||||
- Live (9202, drill catalog, controller 0.340.0): the negative control `failed` and was refused by the writer; the Plex
|
||||
1.43.4 → 1.43.5 walk `proven`; the drill step written; the old controller's night leg skipped it (`not_proven`); a hand
|
||||
press took it. Evidence: felhom.eu `documentation/audits/security-lane-2026-10-23/`.
|
||||
- The live catalog's templates are unchanged; drill entries stay in the drill.
|
||||
@@ -423,9 +423,35 @@ def _drill_bump(app, frm, to, service_hint=None):
|
||||
r = sh(["git", "-C", DRILL, "push", "-q", "origin", "main"], timeout=120)
|
||||
h = sh(["git", "-C", DRILL, "rev-parse", "--short=12", "HEAD"]).stdout.strip()
|
||||
say(f" [5] drill commit {h}: {app} {frm} -> {to} (push rc={r.returncode})")
|
||||
refresh_box_mirror()
|
||||
return h
|
||||
|
||||
|
||||
BOX_VOL = "/var/lib/docker/volumes/felhom-controller-data/_data" # the controller's data volume, guest path
|
||||
BOX_CVOL = "/opt/docker/felhom-controller" # the same, inside the controller container
|
||||
MIRROR_URL = f"file://{BOX_CVOL}/drill-catalog.git"
|
||||
|
||||
|
||||
def refresh_box_mirror():
|
||||
"""A box pointed at the drill through its LOCAL MIRROR (R-992: no catalog credential on the box — the mirror method of
|
||||
felhom.eu audits/burndown-3-2026-10-17/tools/repoint.py) sees a drill commit only after the mirror is loaded again.
|
||||
Without this a drill commit reaches Gitea and never the box, and a walk then presses Update on nothing. A box on any
|
||||
other catalog URL is left alone (it fetches the drill itself)."""
|
||||
conf = guest(f"grep -E '^\\s+repo_url:' {BOX_VOL}/controller.yaml")
|
||||
if MIRROR_URL not in conf:
|
||||
return False
|
||||
import secrets as _s
|
||||
b = f"/tmp/drill-walk-{os.getpid()}-{_s.token_hex(4)}.bundle"
|
||||
sh(["git", "-C", DRILL, "bundle", "create", b, "main"])
|
||||
sh(["scp", "-q", "-o", "StrictHostKeyChecking=accept-new"] + (["-J", _T["jump"]] if _T["jump"] else [])
|
||||
+ [b, f"{_T['ssh']}:{b}"], timeout=120)
|
||||
sh(ssh_args() + [f"pct push {GUEST} {b} {BOX_VOL}/{os.path.basename(b)} && rm -f {b}"], timeout=120)
|
||||
out = guest(f"""docker exec felhom-controller sh -c 'git -C {BOX_CVOL}/drill-catalog.git fetch -q {BOX_CVOL}/{os.path.basename(b)} +main:main && rm -f {BOX_CVOL}/{os.path.basename(b)}; git -C {BOX_CVOL}/drill-catalog.git log -1 --format="%h" main'""")
|
||||
os.remove(b)
|
||||
say(f" [5] the box's drill mirror now at {out.strip()}")
|
||||
return True
|
||||
|
||||
|
||||
def sync_rescan(expect_app=None, expect_ref=None, tries=12, delay=5):
|
||||
"""Sync, rescan, and — when told what to expect — WAIT FOR THE BADGE TO CATCH UP.
|
||||
|
||||
@@ -635,3 +661,248 @@ def restore(name, snapshot_id=None, wait_s=1200):
|
||||
"http": head, "location": loc[:1], "seconds": round(time.time() - t0, 1),
|
||||
"state_after": st.get("state"), "hold_after": st.get("hold_reason"),
|
||||
"observables_after": observables(name)}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ the security-fix walk (D39 = B)
|
||||
|
||||
SECURITY_WALK_VERSION = 1
|
||||
SOAK_DEFAULT_S = 600
|
||||
|
||||
|
||||
def soak(name, seconds, interval=10):
|
||||
"""The box's memory soak (`09` §3 decision 255): every `interval` s for `seconds`, per container of the app, the
|
||||
app's own memory (cgroup `anon`, decision 22 — the cgroup peak counts the file cache) against its limit, the
|
||||
cgroup peak, the OOM-kill counter and the restart count. One guest call; the guest prints one JSON line a sample."""
|
||||
script = f"""
|
||||
set -u
|
||||
ids=$(docker ps -a --filter label=com.docker.compose.project={name} --format '{{{{.ID}}}}')
|
||||
end=$(( $(date +%s) + {int(seconds)} ))
|
||||
while :; do
|
||||
for id in $ids; do
|
||||
full=$(docker inspect -f '{{{{.Id}}}}' $id); nm=$(docker inspect -f '{{{{.Name}}}}' $id | tr -d /)
|
||||
rc=$(docker inspect -f '{{{{.RestartCount}}}}' $id); run=$(docker inspect -f '{{{{.State.Running}}}}' $id)
|
||||
start=$(docker inspect -f '{{{{.State.StartedAt}}}}' $id); oomk=$(docker inspect -f '{{{{.State.OOMKilled}}}}' $id)
|
||||
cg=""; for c in /sys/fs/cgroup/system.slice/docker-$full.scope /sys/fs/cgroup/docker/$full; do [ -d "$c" ] && cg=$c; done
|
||||
anon=0; mx=max; pk=0; ok=0
|
||||
if [ -n "$cg" ]; then
|
||||
anon=$(awk '$1=="anon"{{print $2}}' $cg/memory.stat); mx=$(cat $cg/memory.max)
|
||||
pk=$(cat $cg/memory.peak 2>/dev/null || echo 0); ok=$(awk '$1=="oom_kill"{{print $2}}' $cg/memory.events)
|
||||
fi
|
||||
printf '{{"t":%s,"c":"%s","anon":%s,"max":"%s","peak":%s,"oom_kill":%s,"restarts":%s,"running":"%s","started":"%s","oomkilled":"%s","cg":"%s"}}\\n' \\
|
||||
"$(date +%s)" "$nm" "${{anon:-0}}" "$mx" "${{pk:-0}}" "${{ok:-0}}" "$rc" "$run" "$start" "$oomk" "$cg"
|
||||
done
|
||||
[ "$(date +%s)" -ge "$end" ] && break
|
||||
sleep {int(interval)}
|
||||
done
|
||||
"""
|
||||
out = guest(script, timeout=int(seconds) + 300)
|
||||
samples = []
|
||||
for line in out.splitlines():
|
||||
try:
|
||||
samples.append(json.loads(line))
|
||||
except ValueError:
|
||||
continue
|
||||
per = {}
|
||||
for s in samples:
|
||||
c = per.setdefault(s["c"], {"samples": 0, "anon_peak": 0, "cg_peak": 0, "limit": None, "oom_kill": [],
|
||||
"restarts": [], "running": [], "started": set(), "oomkilled": False, "cgroup": s["cg"]})
|
||||
c["samples"] += 1
|
||||
c["anon_peak"] = max(c["anon_peak"], int(s["anon"]))
|
||||
c["cg_peak"] = max(c["cg_peak"], int(s["peak"]))
|
||||
c["limit"] = int(s["max"]) if str(s["max"]).isdigit() else None
|
||||
c["oom_kill"].append(int(s["oom_kill"]))
|
||||
c["restarts"].append(int(s["restarts"]))
|
||||
c["running"].append(s["running"] == "true")
|
||||
c["started"].add(s["started"])
|
||||
c["oomkilled"] = c["oomkilled"] or s["oomkilled"] == "true"
|
||||
res = {"soak_s": int(seconds), "interval_s": interval, "samples": len(samples), "containers": {}}
|
||||
kills = restarts = 0
|
||||
peaks = []
|
||||
for nm, c in per.items():
|
||||
k = (max(c["oom_kill"]) - min(c["oom_kill"])) if c["oom_kill"] else 0
|
||||
r = (max(c["restarts"]) - min(c["restarts"])) + (len(c["started"]) - 1)
|
||||
kills += k + (1 if c["oomkilled"] else 0)
|
||||
restarts += r
|
||||
pct = round(100.0 * c["anon_peak"] / c["limit"], 1) if c["limit"] else None
|
||||
cgp = round(100.0 * c["cg_peak"] / c["limit"], 1) if c["limit"] else None
|
||||
if pct is not None:
|
||||
peaks.append(pct)
|
||||
res["containers"][nm] = {"samples": c["samples"], "anon_peak_bytes": c["anon_peak"], "limit_bytes": c["limit"],
|
||||
"anon_peak_pct": pct, "cgroup_peak_pct": cgp, "oom_kill_delta": k,
|
||||
"oom_killed_flag": c["oomkilled"], "restarts_delta": r,
|
||||
"running_all_samples": all(c["running"]), "cgroup": c["cgroup"]}
|
||||
res["oom_kills"], res["restarts"] = kills, restarts
|
||||
res["peak_pct"] = max(peaks) if peaks else None
|
||||
return res
|
||||
|
||||
|
||||
def setup_gate_probe(sub):
|
||||
"""How the setup gate (decision 46) answers this app right now, as the household's browser and as a script: status and
|
||||
redirect target only (the cookie is never printed)."""
|
||||
out = {}
|
||||
for label, hdr in (("browser", ["-H", "Accept: text/html"]), ("script", [])):
|
||||
r = sh(["curl", "-sk", "-D", "-", "-o", "/dev/null", "-H", f"Host: {sub}.{DOMAIN}"] + hdr + [f"{BASE}/identity"])
|
||||
st = re.match(r"HTTP/\S+ (\d+)", r.stdout or "")
|
||||
loc = _loc(r.stdout)
|
||||
out[label] = {"status": st.group(1) if st else None, "redirect": re.sub(r"\?.*", "?…", loc) if loc else None}
|
||||
return out
|
||||
|
||||
|
||||
def security_walk(app, frm, to, evdir, soak_s=SOAK_DEFAULT_S, values=None):
|
||||
"""`box_walk.py --security <app> --from <svc=ref,…> --to <svc=ref,…> --ev <dir> [--soak N] [--value K=V …]` — the BOX venue of a
|
||||
security-fix step (`09` §3 decision 255, D39 = B), on scratch guest 9202 pointed at the DRILL catalog, through the
|
||||
product's own endpoints only:
|
||||
1. the drill's template for <app> must stand at FROM (the caller puts it there; this walk never guesses);
|
||||
2. <app> is installed fresh; the four version observables must read FROM;
|
||||
3. seed + read-back when a box fixture has the app, else `seed: "none"` — written, never hidden;
|
||||
4. a DRILL-only commit moves the compose FROM -> TO; sync + rescan until the box's catalog_images carry TO;
|
||||
5. the product's guarded Update, every phase with its time;
|
||||
6. after: final phase `done`, no undo, no hold, the app running, the four observables equal TO, the seed read back;
|
||||
7. the memory soak (default 600 s): a kill or a restart = failed;
|
||||
8. <evdir>/box-verdict-<app>.json: `proven` only if all of that holds; `inconclusive` stays `inconclusive`.
|
||||
The app is removed through the product at the end unless KEEP=1."""
|
||||
import upgrade_fixtures_box as fixtures
|
||||
import upgrade_fixtures_box28 as _f28
|
||||
global LOG
|
||||
LOG = []
|
||||
FX = dict(_f28.FIXTURES28)
|
||||
FX.update(fixtures.FIXTURES)
|
||||
os.makedirs(evdir, exist_ok=True)
|
||||
rec = {"app": app, "walk": "security", "box_walk_version": SECURITY_WALK_VERSION, "verdict": "inconclusive",
|
||||
"venue": f"box {GUEST} (drill catalog), the guarded Update", "from": frm, "to": to}
|
||||
|
||||
def finish(verdict, why):
|
||||
rec["verdict"], rec["why"] = verdict, why
|
||||
rec["log"] = LOG
|
||||
write_verdict(rec, evdir)
|
||||
os.replace(os.path.join(evdir, "verdict.json"), os.path.join(evdir, f"box-verdict-{app}.json"))
|
||||
say(f"RESULT {verdict} — {why}")
|
||||
if not os.environ.get("KEEP") and stack(app).get("deployed"):
|
||||
remove(app)
|
||||
return 0 if verdict == "proven" else 1
|
||||
|
||||
login()
|
||||
conf = guest("grep -A3 '^git:' /var/lib/docker/volumes/felhom-controller-data/_data/controller.yaml")
|
||||
if "app-catalog-drill" not in conf and MIRROR_URL not in conf:
|
||||
return finish("inconclusive", f"guest {GUEST} is not on the drill catalog (nor its local mirror) — nothing done")
|
||||
sh(["git", "-C", DRILL, "pull", "-q", "--rebase", "origin", "main"], timeout=120)
|
||||
drill_imgs = images_of(open(f"{DRILL}/templates/{app}/docker-compose.yml").read())
|
||||
if drill_imgs != frm:
|
||||
return finish("inconclusive", f"the drill's {app} is at {drill_imgs}, not at FROM {frm} — put it there first")
|
||||
fx = FX.get(app)
|
||||
sub = getattr(fx, "sub", app) if fx else app
|
||||
if stack(app).get("deployed"):
|
||||
say(f" [1] removing the existing {app} first (scratch box)")
|
||||
remove(app)
|
||||
sync_rescan()
|
||||
if not deploy(app, sub, values):
|
||||
return finish("inconclusive", "the install at FROM did not complete — nothing was tested")
|
||||
wait_app(sub, "/identity" if app == "plex" else "/", tries=60)
|
||||
rec["observables_before"] = observables(app)
|
||||
if rec["observables_before"]["pinned_images"] != frm:
|
||||
return finish("inconclusive", f"installed at {rec['observables_before']['pinned_images']}, not at FROM")
|
||||
rec["setup_gate_before"] = setup_gate_probe(sub)
|
||||
say(f" [2] setup gate as installed: {rec['setup_gate_before']}")
|
||||
tok = None
|
||||
if fx is None or fx.__class__.__name__ == "NoRoute":
|
||||
rec["seed"] = "none"
|
||||
rec["seed_why"] = getattr(fx, "tried", "no box fixture for this app")
|
||||
say(f" [3] seed: none — {rec['seed_why']}")
|
||||
else:
|
||||
tok = fx.seed(w_self(), sub, say)
|
||||
if tok is None or not fx.verify(w_self(), sub, tok, say):
|
||||
return finish("inconclusive", "C1: the fixture could not seed and read back before the update")
|
||||
rec["seed"] = "read_back"
|
||||
froms = ",".join(frm[s] for s in sorted(frm) if frm[s] != to.get(s))
|
||||
tos = ",".join(to[s] for s in sorted(frm) if frm[s] != to.get(s))
|
||||
rec["drill_commit"] = drill_bump(app, froms, tos)
|
||||
if not rec["drill_commit"]:
|
||||
return finish("inconclusive", "the drill could not be moved FROM -> TO")
|
||||
moved = [s for s in sorted(to) if frm.get(s) != to[s]]
|
||||
rec["sync_waited_s"] = sync_rescan(app, to[moved[0]], tries=40, delay=10)
|
||||
if rec["sync_waited_s"] is None:
|
||||
return finish("inconclusive", f"the box never read TO {to[moved[0]]} from the drill catalog — nothing pressed")
|
||||
rec["badge_before"] = badges(app)
|
||||
rec["measured_at"] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
rec["update"] = press_update(app, poll=1.0, cap_s=1800)
|
||||
time.sleep(15)
|
||||
st = stack(app)
|
||||
rec["observables_after"] = obs = observables(app)
|
||||
rec["badge_after"] = badges(app)
|
||||
rec["state_after"], rec["hold_after"] = st.get("state"), st.get("hold_reason")
|
||||
ii = (st.get("app_config") or {}).get("installed_images") or {}
|
||||
rec["to_digests"] = {s: (ii.get(s) or {}).get("digest") if isinstance(ii.get(s), dict) else None for s in to}
|
||||
u = rec["update"]
|
||||
if not u.get("accepted"):
|
||||
return finish("failed", f"the Update was refused: {u.get('http')} {str(u.get('refusal'))[:200]}")
|
||||
if u.get("final_phase") != "done" or u.get("update_error") or rec["hold_after"]:
|
||||
return finish("failed", f"the update ended {u.get('final_phase')!r} (error {u.get('update_error')!r}, hold {rec['hold_after']!r})")
|
||||
live = sorted({l.split("image:", 1)[1].strip() for l in obs.get("live_compose_image_lines") or [] if "image:" in l})
|
||||
four = {"pinned": obs.get("pinned_images"), "installed": obs.get("installed_images"), "catalog": obs.get("catalog_images"),
|
||||
"live_compose": live}
|
||||
rec["four_observables"] = four
|
||||
running = {l.split()[1] for l in obs.get("docker_inspect") or [] if "running=true" in l}
|
||||
bad = {k: v for k, v in four.items() if k != "live_compose" and v != to}
|
||||
if bad or set(live) != set(to.values()) or not set(to.values()) <= running:
|
||||
return finish("failed", f"the version observables are not TO: {bad or four['live_compose']}, running {sorted(running)}")
|
||||
if rec["state_after"] != "running":
|
||||
return finish("failed", f"the app is {rec['state_after']!r} after the update")
|
||||
if tok is not None:
|
||||
rec["seed_read_after"] = fx.verify(w_self(), sub, tok, say)
|
||||
if not rec["seed_read_after"]:
|
||||
return finish("failed", "the seed did not read back after the update")
|
||||
if any(not d for d in rec["to_digests"].values()):
|
||||
return finish("inconclusive", f"the box recorded no digest for a TO service: {rec['to_digests']}")
|
||||
rec["setup_gate_after"] = setup_gate_probe(sub)
|
||||
say(f" [7] memory soak {soak_s} s …")
|
||||
rec["memory"] = m = soak(app, soak_s)
|
||||
say(f" [7] soak: peak {m.get('peak_pct')}% of the limit (anon), kills {m.get('oom_kills')}, restarts {m.get('restarts')}")
|
||||
if m.get("samples", 0) == 0 or m.get("peak_pct") is None:
|
||||
return finish("inconclusive", "the soak read no sample — not a pass")
|
||||
if m["oom_kills"] or m["restarts"] or not all(c["running_all_samples"] for c in m["containers"].values()):
|
||||
return finish("failed", f"the soak saw {m['oom_kills']} OOM kill(s) and {m['restarts']} restart(s)")
|
||||
return finish("proven", "the security-fix step ran on the box through the guarded Update; healthy, TO on all four "
|
||||
"observables, no undo, no hold, a clean soak" + ("" if tok is None else ", seed read back"))
|
||||
|
||||
|
||||
def images_of(compose_text):
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import ladder
|
||||
return ladder.images_in(compose_text)
|
||||
|
||||
|
||||
def w_self():
|
||||
return sys.modules[__name__]
|
||||
|
||||
|
||||
def _refs(spec):
|
||||
"""`svc=ref,svc2=ref2` -> {svc: ref}."""
|
||||
out = {}
|
||||
for part in spec.split(","):
|
||||
k, _, v = part.strip().partition("=")
|
||||
if k and v:
|
||||
out[k] = v
|
||||
return out
|
||||
|
||||
|
||||
def main(argv):
|
||||
ap = argparse.ArgumentParser(prog="box_walk.py")
|
||||
ap.add_argument("--security", metavar="APP", required=True,
|
||||
help="the security-fix walk (09 decision 255) for this app")
|
||||
ap.add_argument("--from", dest="frm", required=True, help="svc=ref,… the drill must stand at")
|
||||
ap.add_argument("--to", required=True, help="svc=ref,… the step moves to")
|
||||
ap.add_argument("--ev", required=True, help="evidence directory")
|
||||
ap.add_argument("--soak", type=int, default=SOAK_DEFAULT_S)
|
||||
ap.add_argument("--value", action="append", default=[], metavar="KEY=VAL",
|
||||
help="a deploy field the wizard would get from the household (e.g. HDD_PATH=<the drive>)")
|
||||
a = ap.parse_args(argv)
|
||||
frm, to = _refs(a.frm), _refs(a.to)
|
||||
if set(frm) != set(to):
|
||||
print("box_walk: --from and --to must name the same services")
|
||||
return 2
|
||||
vals = dict(v.split("=", 1) for v in a.value if "=" in v)
|
||||
return security_walk(a.security, frm, to, a.ev, a.soak, vals or None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
@@ -16,7 +16,8 @@ For every template whose per-service images differ between A and B, the `.felhom
|
||||
carry, in an `update_ladder:` line that was NOT there at A, an entry that
|
||||
- is well-formed (ladder.check_entry) and NOT `backfilled` (a backfill cites an old record; a new
|
||||
move needs a new test),
|
||||
- has `verdict: "proven"`,
|
||||
- has `verdict: "proven"` — or `"security_fix"` (`09` §3 decision 255, D39 = B: an urgent upstream fix proven on the
|
||||
box, bench optional; its own fields are ladder.check_security's), judged here exactly like a proven one,
|
||||
- has `from` equal to the images at A and `to` equal to the images at B, service by service,
|
||||
- carries digests that the registry STILL serves for those refs right now (decision 17). A digest
|
||||
that moved since the test means the image that was tested is not the image a box would pull;
|
||||
@@ -117,8 +118,9 @@ def judge_app(app, a, b, resolver, network=True):
|
||||
problems.append("new entry: " + p)
|
||||
if e.get("backfilled") is not None:
|
||||
problems.append("new entry is marked backfilled — a new move needs a new test, not an old record")
|
||||
if e.get("verdict") != "proven":
|
||||
problems.append("new entry's verdict is %r — only a PROVEN step may be published" % e.get("verdict"))
|
||||
if e.get("verdict") not in ("proven", ladder.SECURITY_FIX):
|
||||
problems.append("new entry's verdict is %r — only a PROVEN or a SECURITY-FIX step may be published"
|
||||
% e.get("verdict"))
|
||||
if e.get("from") != before:
|
||||
problems.append("new entry's `from` %s is not the compose before the move %s" % (e.get("from"), before))
|
||||
if (e.get("marks") or {}).get("memory_tight"):
|
||||
|
||||
@@ -13,7 +13,7 @@ is shallow (the R-452 gap that skips every history gate there). Its twin
|
||||
|
||||
WHAT IT CHECKS, per template that carries `update_ladder:` (format and field rules: ladder.py):
|
||||
1. every line of the block is a one-line JSON entry, and every entry is well-formed
|
||||
(verdict proven|unrecorded only; a sha256 digest per `to` service; the memory watch's peak on
|
||||
(verdict proven|unrecorded|security_fix only; a sha256 digest per `to` service; the memory watch's peak on
|
||||
any entry not backfilled; marks.memory_tight agrees with the peak);
|
||||
2. the ladder is CONTINUOUS — each entry's `from` is the previous entry's `to`;
|
||||
2b. a RE-TEST (`from` == `to`, `09` §3 decision 52) starts FROM the previous entry's digest
|
||||
@@ -27,6 +27,9 @@ WHAT IT CHECKS, per template that carries `update_ladder:` (format and field rul
|
||||
4b. ... and its own `.felhom.yml` at `steps/<step_key(to)>.felhom.yml` (R-664), with a healthcheck
|
||||
when the template has one.
|
||||
|
||||
5. (WARN, never a refusal — `09` §3 decision 255) a template whose NEWEST step is a `security_fix` with no bench
|
||||
`evidence` prints one line, so a step that skipped the bench stays visible on every push.
|
||||
|
||||
A template WITHOUT a ladder passes here — it has never been moved since the gate existed, and its
|
||||
first move is refused by the twin unless that move brings the first entry.
|
||||
|
||||
@@ -100,6 +103,21 @@ def check_app(app_dir):
|
||||
return problems
|
||||
|
||||
|
||||
def security_warning(app, app_dir):
|
||||
"""The one WARN line of rule 5, or None: the ladder's head is a security_fix step with no bench test."""
|
||||
fy = os.path.join(app_dir, ".felhom.yml")
|
||||
if not os.path.exists(fy):
|
||||
return None
|
||||
entries, _r, _e = ladder.parse(open(fy, encoding="utf-8").read())
|
||||
if not entries:
|
||||
return None
|
||||
head = entries[-1]
|
||||
if head.get("verdict") != ladder.SECURITY_FIX or head.get("evidence"):
|
||||
return None
|
||||
to = ",".join("%s" % r for _s, r in sorted((head.get("to") or {}).items()))
|
||||
return "%s: security-fix step %s has no bench test (since %s)" % (app, to, head.get("tested_at"))
|
||||
|
||||
|
||||
def main(argv):
|
||||
root = ROOT
|
||||
if "--root" in argv:
|
||||
@@ -122,6 +140,9 @@ def main(argv):
|
||||
if "update_ladder:" in text:
|
||||
with_ladder += 1
|
||||
probs = check_app(d)
|
||||
warn = security_warning(app, d)
|
||||
if warn:
|
||||
print("WARN " + warn)
|
||||
if probs:
|
||||
convicted.append(app)
|
||||
for p in probs:
|
||||
|
||||
+111
-3
@@ -40,6 +40,22 @@ AN ENTRY (all keys required unless marked):
|
||||
the previous entry's `digest`. Written by `upgrade-test.py --write-ladder` from a
|
||||
`--retest` verdict, never by hand.
|
||||
|
||||
A SECURITY-FIX STEP (`09` §3 decision 255, D39 = B, 2026-10-23): `"verdict": "security_fix"` — an urgent upstream
|
||||
fix that skipped the bench. The night leg takes it like a proven step (controller >= 0.341.0; an older controller
|
||||
skips it at night as `not_proven` and a person's press still takes it). Beyond the keys above it needs:
|
||||
security {"ids": ["CVE-YYYY-NNNN…" | "GHSA-xxxx-xxxx-xxxx", …], "advisory": "https://…",
|
||||
"fixed_in": "<the first fixed upstream version, as the advisory states it>"} — the public
|
||||
notice IS the authority (no operator word per incident)
|
||||
box_evidence required: the box walk (`box_walk.py --security`) on 9202, through the product's Update
|
||||
seed "read_back" (a box fixture seeded and read it back after the update) | "none" (the app has
|
||||
no box fixture — said, never hidden)
|
||||
memory_peak_pct from the BOX soak; `memory_basis` names the venue ("box_soak")
|
||||
evidence the bench record, or null when no bench ran. A bench given must be proven: `bench_verdict`
|
||||
"proven" and `harness_version` >= 2 ride with it; with no bench both are null
|
||||
It may NOT carry `backfilled`, `digest_from` (a same-tag fix is decision 52's lane), `engine_conversion`, nor cross
|
||||
a database engine MAJOR (the judgement is check-engine-major.py's own `engine_of`/`major_of`, imported, not copied).
|
||||
Written only by `upgrade-test.py --write-ladder --security`.
|
||||
|
||||
STEP DEFINITIONS (`09` §6.4 part 5, controller v0.268.0): every entry but the NEWEST carries its own
|
||||
complete compose file at `templates/<app>/steps/<step_key(to)>.yml` — the box climbs one step at a time
|
||||
and pins exactly that file; the newest step's definition is the template's `docker-compose.yml`. The box's
|
||||
@@ -50,7 +66,9 @@ SAME way by the controller (`stacks.StepKey`, pinned by TestLadder_StepKeyMatche
|
||||
Every path that reads or writes the format is here, so the gate and the writer cannot disagree.
|
||||
"""
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
LADDER_KEY_RE = re.compile(r"^update_ladder:\s*$")
|
||||
@@ -60,10 +78,86 @@ IMAGE_RE = re.compile(r"^\s+image:\s*[\"']?([^\s\"'#]+)")
|
||||
DIGEST_RE = re.compile(r"^sha256:[0-9a-f]{64}$")
|
||||
TS_RE = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$")
|
||||
DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
|
||||
VERDICTS = ("proven", "unrecorded")
|
||||
VERDICTS = ("proven", "unrecorded", "security_fix")
|
||||
SECURITY_FIX = "security_fix"
|
||||
SECURITY_ID_RE = re.compile(r"^(CVE-\d{4}-\d{4,}|GHSA(-[23456789cfghjmpqrvwx]{4}){3})$")
|
||||
SEEDS = ("read_back", "none")
|
||||
MEMORY_TIGHT_PCT = 80.0
|
||||
|
||||
|
||||
def _engine_major_module():
|
||||
"""check-engine-major.py, loaded by path (its name has a hyphen) — the ONE judgement of what a database engine is
|
||||
and what its major is. Reused, never copied (D39 = B, §3.2 rule 2)."""
|
||||
p = os.path.join(os.path.dirname(os.path.abspath(__file__)), "check-engine-major.py")
|
||||
spec = importlib.util.spec_from_file_location("check_engine_major", p)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
||||
|
||||
def engine_majors_crossed(frm, to):
|
||||
"""[(service, engine, major_from, major_to), …] — every database engine service whose MAJOR differs between
|
||||
`frm` and `to`. A major nobody can read is reported with None (a conviction for a security step, never a pass)."""
|
||||
em = _engine_major_module()
|
||||
out = []
|
||||
for svc, ref in sorted((to or {}).items()):
|
||||
a, b = em.engine_of((frm or {}).get(svc, "")), em.engine_of(ref)
|
||||
if not b or not a:
|
||||
continue
|
||||
ma, mb = em.major_of(a[1]), em.major_of(b[1])
|
||||
if ma is None or mb is None or ma != mb:
|
||||
out.append((svc, b[0], ma, mb))
|
||||
return out
|
||||
|
||||
|
||||
def check_security(e):
|
||||
"""Problems with a security_fix entry's own fields (D39 = B). Called by check_entry."""
|
||||
p = []
|
||||
sec = e.get("security")
|
||||
if not isinstance(sec, dict):
|
||||
return ["a security_fix step needs a security block {ids, advisory, fixed_in} — the public notice is its authority"]
|
||||
ids = sec.get("ids")
|
||||
if not (isinstance(ids, list) and ids):
|
||||
p.append("security.ids must list at least one CVE or GHSA id")
|
||||
else:
|
||||
bad = [i for i in ids if not (isinstance(i, str) and SECURITY_ID_RE.match(i))]
|
||||
if bad:
|
||||
p.append("security.ids %s are not CVE-YYYY-NNNN or GHSA-xxxx-xxxx-xxxx ids" % bad)
|
||||
adv = sec.get("advisory")
|
||||
if not (isinstance(adv, str) and re.match(r"^https://[^\s/]+\.[^\s]+$", adv)):
|
||||
p.append("security.advisory must be the notice's https:// address (got %r)" % (adv,))
|
||||
if not (isinstance(sec.get("fixed_in"), str) and sec["fixed_in"].strip()):
|
||||
p.append("security.fixed_in must name the first fixed upstream version")
|
||||
if not (isinstance(e.get("box_evidence"), str) and e["box_evidence"].strip()):
|
||||
p.append("a security_fix step must cite its box walk: box_evidence is missing")
|
||||
if e.get("seed") not in SEEDS:
|
||||
p.append("a security_fix step must say what was read back: seed is %r, not one of %s" % (e.get("seed"), "/".join(SEEDS)))
|
||||
if not (isinstance(e.get("memory_basis"), str) and e["memory_basis"].startswith("box")):
|
||||
p.append("a security_fix step's memory_peak_pct comes from the box soak: memory_basis must name it (box_…)")
|
||||
ev = e.get("evidence")
|
||||
if ev is None:
|
||||
if e.get("bench_verdict") is not None or e.get("harness_version") is not None:
|
||||
p.append("a security_fix step with no bench evidence carries no bench_verdict or harness_version")
|
||||
elif not (isinstance(ev, str) and ev.strip()):
|
||||
p.append("security_fix evidence is the bench record's path, or null when no bench ran")
|
||||
else:
|
||||
if e.get("bench_verdict") != "proven":
|
||||
p.append("a security_fix step that cites a bench run needs that run PROVEN (bench_verdict %r) — a failed "
|
||||
"bench is evidence against the step, never for it" % (e.get("bench_verdict"),))
|
||||
if not isinstance(e.get("harness_version"), int) or e["harness_version"] < 2:
|
||||
p.append("a security_fix step that cites a bench run needs its harness_version >= 2 (the memory watch)")
|
||||
for k, why in (("backfilled", "a backfill cites an old record; a security fix is a new test"),
|
||||
("digest_from", "a same-tag fix is a decision-52 re-test, not a security_fix step"),
|
||||
("engine_conversion", "a security_fix step may not convert a database")):
|
||||
if e.get(k) is not None:
|
||||
p.append("a security_fix step may not carry %s (%s)" % (k, why))
|
||||
if e.get("from") == e.get("to"):
|
||||
p.append("a security_fix step must move an image (from == to is a decision-52 re-test)")
|
||||
for svc, eng, a, b in engine_majors_crossed(e.get("from"), e.get("to")):
|
||||
p.append("a security_fix step may not cross a database engine major: %s (%s) %s -> %s" % (svc, eng, a, b))
|
||||
return p
|
||||
|
||||
|
||||
def images_in(compose_text):
|
||||
"""{service: image} — per service, from that service's OWN `image:` line (the same reading
|
||||
check-engine-major.py and check-catalog-since.py make)."""
|
||||
@@ -145,7 +239,21 @@ def check_entry(e):
|
||||
for svc in e["digest"]:
|
||||
if svc not in e["to"]:
|
||||
p.append("digest names a service %r that `to` does not" % svc)
|
||||
if e["from"] == e["to"] and v == "proven" and backfilled is None: # a RE-TEST (decision 52)
|
||||
if v == SECURITY_FIX:
|
||||
p.extend(check_security(e))
|
||||
if not (isinstance(e["tested_at"], str) and TS_RE.match(e["tested_at"])):
|
||||
p.append("a security_fix step needs tested_at (the box walk's time) as an RFC 3339 time")
|
||||
peak = e["memory_peak_pct"]
|
||||
if not isinstance(peak, (int, float)) or isinstance(peak, bool):
|
||||
p.append("a security_fix step needs memory_peak_pct from the box soak")
|
||||
elif isinstance(e["marks"], dict) and bool(e["marks"].get("memory_tight")) != (peak > MEMORY_TIGHT_PCT):
|
||||
p.append("marks.memory_tight=%s disagrees with memory_peak_pct=%s (tight above %d%%)"
|
||||
% (e["marks"].get("memory_tight"), peak, MEMORY_TIGHT_PCT))
|
||||
elif e.get("security") is not None or e.get("seed") is not None:
|
||||
p.append("security / seed belong only to a security_fix step")
|
||||
if v == SECURITY_FIX:
|
||||
pass # digest_from is judged by check_security, with its own sentence
|
||||
elif e["from"] == e["to"] and v == "proven" and backfilled is None: # a RE-TEST (decision 52)
|
||||
df = e.get("digest_from")
|
||||
if not isinstance(df, dict) or set(df) != set(e["to"]) or not all(isinstance(x, str) and DIGEST_RE.match(x) for x in df.values()):
|
||||
p.append("a re-test (from == to) needs digest_from: {service: sha256} for every service — the digest it was tested FROM")
|
||||
@@ -187,7 +295,7 @@ def check_entry(e):
|
||||
def entry_line(e):
|
||||
"""The one line the writer emits for an entry — key order fixed so diffs stay readable."""
|
||||
order = ["from", "to", "digest", "verdict", "tested_at", "harness_version", "evidence",
|
||||
"box_evidence", "memory_peak_pct", "marks", "backfilled", "note"]
|
||||
"box_evidence", "memory_peak_pct", "marks", "backfilled", "security", "seed", "note"]
|
||||
ordered = {k: e[k] for k in order if k in e}
|
||||
for k in e:
|
||||
if k not in ordered:
|
||||
|
||||
@@ -74,7 +74,9 @@ class CatalogGatesFastTest(unittest.TestCase):
|
||||
# update this count; found by burndown 3, because this file is in no gate run either).
|
||||
# 20 since 2026-10-17: gate-decoys (R-1115) — the decoy suite itself; ~3 min, so the full run only.
|
||||
# 21 since the same day: redis-persistence (R-1096) — fast, no history: the hook AND CI.
|
||||
self.assertEqual(len(mod.GATES), 21)
|
||||
# 24 by 2026-10-23: privileges, download-binds and security-scan (R-986) — STALE AGAIN until then (found by the
|
||||
# D39 security-lane session; this file is still in no gate run).
|
||||
self.assertEqual(len(mod.GATES), 24)
|
||||
self.assertIn("redis-persistence", [g[0] for g in mod.GATES if g[3] and not g[4]])
|
||||
self.assertIn("db-credentials", [g[0] for g in mod.GATES if g[3] and not g[4]])
|
||||
self.assertIn("login-kind", [g[0] for g in mod.GATES if g[3] and not g[4]])
|
||||
@@ -104,7 +106,11 @@ class CatalogGatesFastTest(unittest.TestCase):
|
||||
"""On a --depth 1 clone (what CI has) the runner must SKIP engine-major and SAY so — never
|
||||
convict every push, never pass silently. Asserted on a real shallow clone of this repo."""
|
||||
import shutil, tempfile
|
||||
tmp = tempfile.mkdtemp(prefix="catalog-shallow-")
|
||||
parent = tempfile.mkdtemp(prefix="catalog-shallow-")
|
||||
# the security-scan gate reads the SHARED gate from the sibling felhom.eu clone and fails when it is absent
|
||||
# (never a skip) — so the clone gets the real sibling beside it, as CI's checkout does
|
||||
os.symlink(os.path.join(os.path.dirname(ROOT), "felhom.eu"), os.path.join(parent, "felhom.eu"))
|
||||
tmp = os.path.join(parent, "app-catalog-felhom.eu")
|
||||
try:
|
||||
subprocess.run(["git", "clone", "-q", "--depth", "1", "file://" + ROOT, tmp],
|
||||
check=True, capture_output=True)
|
||||
@@ -119,7 +125,7 @@ class CatalogGatesFastTest(unittest.TestCase):
|
||||
self.assertNotIn("engine-major gate OK", out)
|
||||
self.assertEqual(p.returncode, 0, out)
|
||||
finally:
|
||||
shutil.rmtree(tmp, ignore_errors=True)
|
||||
shutil.rmtree(parent, ignore_errors=True)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ COVERS = {
|
||||
"probe-matches-compose": "the probe TARGET resolves by exact name, explicit `container`, or a UNIQUE prefix - an ambiguity is refused, not guessed (R-630); the DEGRADED no-PyYAML mode CI actually runs; the port/path moved in a COMMENT, in traefik's loadbalancer label, in "
|
||||
"`ports:`/`expose:`, or on a NON-probed service - none of which is where "
|
||||
"the app listens; vs a real probe port/path that the app does not answer (R-618)",
|
||||
"test-record": "a ladder whose newest step is not the compose's images (a move without a record), a gap, a line that is not one JSON entry, a failed verdict - vs a clean ladder (09 decision 13)",
|
||||
"test-record-move": "an image move with NO entry, with the entry only in a COMMENT or in README, with a failed/backfilled entry, with a digest the registry no longer serves, memory_tight without a raised limit - vs a proven entry that matches; a ref moving in a compose COMMENT is not a move (09 decision 13)",
|
||||
"test-record": "a ladder whose newest step is not the compose's images (a move without a record), a gap, a line that is not one JSON entry, a failed verdict - vs a clean ladder (09 decision 13); a security_fix head with no bench prints its WARN and passes (09 decision 255)",
|
||||
"test-record-move": "an image move with NO entry, with the entry only in a COMMENT or in README, with a failed/backfilled entry, with a digest the registry no longer serves, memory_tight without a raised limit - vs a proven entry that matches; a ref moving in a compose COMMENT is not a move (09 decision 13); a SECURITY-FIX step (09 decision 255): the CVE ids only in a note with no security block, a non-CVE/GHSA id, an http advisory, no seed, a digest_from, a failed bench, a PostgreSQL major - each refused; vs a box-only security_fix that matches",
|
||||
"probe-measured": "the measurement written in the TAGLINE or another comment block, not directly above setup_done_probe:; a date with no before/after; before/after with no date; 'read upstream' instead of 'measured' - vs a genuine measured comment (R-715)",
|
||||
"family-gate": "family_gate written only in a COMMENT (not gated, no min_controller owed); min_controller only in a comment; a golden DIRECTORY named 0.287.0 with no bake log (the mkdir shape, R-410); a sibling with no golden (stated NOT CHECKED, never a pass of rule 3) - vs the facts: an unanchorable exception (regex, '/', '..'), an exception list with no gate, min_controller below 0.287.0, the newest baked golden below 0.287.0; and a genuine family app passes (decisions 63/64, finding F1)",
|
||||
"onboarding": "a NEW template with no record; a record missing an id, or carrying it only inside an HTML comment; a `done` whose path does not exist, is an EMPTY directory (the mkdir shape, R-410) or names an absent sibling-repo file; an `n/a` with an empty or two-word reason; an `open` row; `opened:` backdated before the checklist; the template a new app copies lacking a new id - vs a complete record, an id added after `opened:`, and an exempt app's record with open rows (NEW-APP-CHECKLIST.md)",
|
||||
@@ -322,6 +322,8 @@ def strip_ladder(t):
|
||||
return t
|
||||
|
||||
|
||||
DROP = object() # a key a decoy leaves OUT of a security_fix entry
|
||||
|
||||
# ── test record (09 §3 decision 13) ────────────────────────────────────────────────────────────
|
||||
TR_D1 = "sha256:" + "a" * 64
|
||||
TR_D2 = "sha256:" + "b" * 64
|
||||
@@ -430,6 +432,53 @@ def test_record_cases(clone):
|
||||
(), table)
|
||||
case_tr_move("DECOY: a ref moves in a compose COMMENT only", clone,
|
||||
[(NC, lambda t: t + "\n# was: deluan/navidrome:0.63.2\n")], 0, (), table)
|
||||
|
||||
# ── D39 = B (`09` §3 decision 255): the security-fix step — box walk required, bench optional ──────────────
|
||||
print("-- test-record-move: a SECURITY-FIX step (D39 = B)")
|
||||
def sec(frm_, to_, digest_, **over):
|
||||
e = {"verdict": "security_fix", "harness_version": None, "evidence": None,
|
||||
"box_evidence": "felhom.eu/documentation/audits/x/box/", "memory_peak_pct": 12.5, "memory_basis": "box_soak",
|
||||
"security": {"ids": ["CVE-2026-96652", "GHSA-2c4m-59x9-fr2g"],
|
||||
"advisory": "https://www.cisa.gov/known-exploited-vulnerabilities-catalog", "fixed_in": "1.43.3.10861"},
|
||||
"seed": "none"}
|
||||
e.update(over)
|
||||
drop = [k for k, v in over.items() if v is DROP]
|
||||
line = tr_entry(frm_, to_, digest_, **{k: v for k, v in e.items() if k not in drop and k != "verdict"},
|
||||
verdict="security_fix")
|
||||
return line
|
||||
case_tr_move("GENUINE: a security_fix step, box only, digest served", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1})))], 0, ("test-record-move gate",), table)
|
||||
case_tr_move("DECOY: the CVE ids only in a `note`, no security block", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1}, security=DROP,
|
||||
note="fixes CVE-2026-96652, see https://www.cisa.gov/kev")))], 1,
|
||||
("needs a security block",), table)
|
||||
case_tr_move("FACT: an id that is neither CVE nor GHSA", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1},
|
||||
security={"ids": ["OSV-2026-1"], "advisory": "https://osv.dev/x", "fixed_in": "1.0"})))], 1,
|
||||
("are not CVE-YYYY-NNNN or GHSA",), table)
|
||||
case_tr_move("FACT: the advisory is http://, not https://", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1},
|
||||
security={"ids": ["CVE-2026-96652"], "advisory": "http://www.cisa.gov/kev", "fixed_in": "1.0"})))], 1,
|
||||
("must be the notice's https://",), table)
|
||||
case_tr_move("FACT: seed is missing", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1}, seed=DROP)))], 1,
|
||||
("seed is None",), table)
|
||||
case_tr_move("FACT: a security_fix carrying digest_from (a same-tag re-test)", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1}, digest_from={"navidrome": TR_D2})))], 1,
|
||||
("may not carry digest_from",), table)
|
||||
case_tr_move("FACT: a security_fix citing a FAILED bench run", clone,
|
||||
[move, (NF, tr_append(sec(frm, to, {"navidrome": TR_D1}, evidence="felhom.eu/x/bench/",
|
||||
bench_verdict="failed", harness_version=3)))], 1,
|
||||
("needs that run PROVEN",), table)
|
||||
DC, DF = "templates/docmost/docker-compose.yml", "templates/docmost/.felhom.yml"
|
||||
dfrm = {s_: cur_image(clone, DC, s_) for s_ in ("docmost", "docmost-postgres", "docmost-redis")}
|
||||
pg_old = dfrm["docmost-postgres"]
|
||||
pg_new = "postgres:%d-alpine" % (int(pg_old.split(":")[1].split("-")[0]) + 1) # READ, then one major up
|
||||
dto = dict(dfrm, **{"docmost-postgres": pg_new})
|
||||
case_tr_move("FACT: a security_fix that crosses a PostgreSQL major", clone,
|
||||
[(DC, swap_image("docmost-postgres", pg_old, pg_new)),
|
||||
(DF, tr_append(sec(dfrm, dto, {s_: TR_D1 for s_ in dto})))], 1,
|
||||
("may not cross a database engine major",), {r: TR_D1 for r in dto.values()})
|
||||
print("-- test-record (static): the newest step IS the compose")
|
||||
def ladder_of(*lines):
|
||||
"""Replace the template's ladder with exactly these entry lines."""
|
||||
@@ -443,6 +492,13 @@ def test_record_cases(clone):
|
||||
case_tr_static("FACT: a gap between steps", clone,
|
||||
[(NF, ladder_of(tr_entry({"navidrome": "deluan/navidrome:0.0.1"}, {"navidrome": "deluan/navidrome:0.0.2"}, {"navidrome": TR_D1}), head))],
|
||||
1, ("the ladder has a gap",))
|
||||
case_tr_static("WARN: the head is a security_fix with no bench test", clone,
|
||||
[(NF, ladder_of(tr_entry({"navidrome": prev}, frm, {"navidrome": TR_D1}, verdict="security_fix",
|
||||
harness_version=None, evidence=None, box_evidence="felhom.eu/x/box/",
|
||||
memory_basis="box_soak", seed="none",
|
||||
security={"ids": ["CVE-2026-96652"], "advisory": "https://www.cisa.gov/kev",
|
||||
"fixed_in": "1.43.3.10861"})))],
|
||||
0, ("WARN navidrome: security-fix step %s has no bench test (since 2026-09-23T22:00:00Z)" % old,))
|
||||
case_tr_static("FACT: a failed verdict sits in the ladder", clone,
|
||||
[(NF, ladder_of(tr_entry({"navidrome": prev}, frm, {"navidrome": TR_D1}, verdict="failed")))],
|
||||
1, ("not allowed in a ladder",))
|
||||
|
||||
@@ -227,5 +227,119 @@ class WriterTest(unittest.TestCase):
|
||||
self.assertEqual(rc, 1); self.assertIn("re-run", out)
|
||||
|
||||
|
||||
# ── D39 = B (`09` §3 decision 255): the security-fix step — box walk required, bench optional ──────────────────
|
||||
SEC_IDS = "CVE-2026-96652,CVE-2026-96654"
|
||||
SEC_URL = "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
|
||||
|
||||
|
||||
def box_walk_record(app, frm, to, verdict="proven", digest=D, peak=12.5, seed="none", walk="security"):
|
||||
return {"app": app, "walk": walk, "verdict": verdict, "from": frm, "to": to,
|
||||
"to_digests": {s: digest for s in to}, "measured_at": "2026-10-23T12:00:00Z", "seed": seed,
|
||||
"memory": {"peak_pct": peak, "soak_s": 600}}
|
||||
|
||||
|
||||
class SecurityWriterTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.mkdtemp(prefix="ladder-security-")
|
||||
for app in ("navidrome", "docmost"):
|
||||
shutil.copytree(os.path.join(ROOT, "templates", app), os.path.join(self.tmp, "templates", app))
|
||||
fy = os.path.join(self.tmp, "templates", app, ".felhom.yml")
|
||||
text = open(fy).read()
|
||||
if "update_ladder:" in text:
|
||||
open(fy, "w").write(text[:text.index("\n# update_ladder")] + "\n")
|
||||
shutil.rmtree(os.path.join(self.tmp, "templates", app, "steps"), ignore_errors=True)
|
||||
self.fy = os.path.join(self.tmp, "templates", "navidrome", ".felhom.yml")
|
||||
self.comp = os.path.join(self.tmp, "templates", "navidrome", "docker-compose.yml")
|
||||
self._orig = image_digest.resolve
|
||||
image_digest.resolve = lambda ref: (D, None)
|
||||
self.frm = {"navidrome": "deluan/navidrome:" + LIVE}
|
||||
self.to = {"navidrome": "deluan/navidrome:" + NEXT}
|
||||
|
||||
def tearDown(self):
|
||||
image_digest.resolve = self._orig
|
||||
shutil.rmtree(self.tmp, ignore_errors=True)
|
||||
|
||||
def run_sec(self, box, bench_rec=None, drop=(), over=None):
|
||||
xp = os.path.join(self.tmp, "box.json")
|
||||
json.dump(box, open(xp, "w"))
|
||||
args = {"--ids": SEC_IDS, "--advisory": SEC_URL, "--fixed-in": "1.43.3.10861", "--box": xp,
|
||||
"--box-evidence": "felhom.eu/documentation/audits/x/box/", "--catalog": self.tmp}
|
||||
args.update(over or {})
|
||||
argv = ["--security"]
|
||||
for k, v in args.items():
|
||||
if k not in drop:
|
||||
argv += [k, v]
|
||||
if bench_rec is not None:
|
||||
bp = os.path.join(self.tmp, "bench.json")
|
||||
json.dump(bench_rec, open(bp, "w"))
|
||||
argv += [bp, "--evidence", "felhom.eu/documentation/audits/x/bench/"]
|
||||
buf = io.StringIO()
|
||||
with redirect_stdout(buf):
|
||||
rc = ut.write_ladder(argv)
|
||||
return rc, buf.getvalue()
|
||||
|
||||
def gate(self, app="navidrome"):
|
||||
import subprocess
|
||||
return subprocess.run([sys.executable, os.path.join(HERE, "check-test-record.py"), "--root", self.tmp, app],
|
||||
capture_output=True, text=True)
|
||||
|
||||
def test_writes_a_box_only_step_the_gate_accepts_and_warns_about(self):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to))
|
||||
self.assertEqual(rc, 0, out)
|
||||
e = ladder.parse(open(self.fy).read())[0][-1]
|
||||
self.assertEqual(e["verdict"], "security_fix")
|
||||
self.assertEqual(e["security"]["ids"], ["CVE-2026-96652", "CVE-2026-96654"])
|
||||
self.assertIsNone(e["evidence"]); self.assertIsNone(e["harness_version"])
|
||||
self.assertEqual((e["seed"], e["memory_peak_pct"], e["memory_basis"]), ("none", 12.5, "box_soak"))
|
||||
self.assertEqual(ladder.check_entry(e), [])
|
||||
self.assertEqual(ladder.images_in(open(self.comp).read()), self.to) # the compose moved
|
||||
r = self.gate()
|
||||
self.assertEqual(r.returncode, 0, r.stdout)
|
||||
self.assertIn("WARN navidrome: security-fix step deluan/navidrome:%s has no bench test (since 2026-10-23T12:00:00Z)" % NEXT, r.stdout)
|
||||
|
||||
def test_a_proven_bench_rides_with_it_and_silences_the_warning(self):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to), bench_rec=bench())
|
||||
self.assertEqual(rc, 0, out)
|
||||
e = ladder.parse(open(self.fy).read())[0][-1]
|
||||
self.assertEqual((e["bench_verdict"], e["harness_version"]), ("proven", 3))
|
||||
self.assertNotIn("WARN", self.gate().stdout)
|
||||
|
||||
def test_refuses_a_box_walk_that_is_not_proven(self):
|
||||
for v in ("failed", "inconclusive"):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to, verdict=v))
|
||||
self.assertEqual(rc, 1); self.assertIn("only a PROVEN `box_walk.py --security` walk", out)
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to, walk="retest"))
|
||||
self.assertEqual(rc, 1); self.assertIn("only a PROVEN", out)
|
||||
self.assertNotIn("update_ladder:", open(self.fy).read())
|
||||
|
||||
def test_refuses_a_bench_that_is_given_and_not_proven(self):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to), bench_rec=bench(verdict="failed"))
|
||||
self.assertEqual(rc, 1); self.assertIn("a bench given must be PROVEN", out)
|
||||
|
||||
def test_refuses_when_the_template_is_not_at_the_walks_from(self):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", {"navidrome": "deluan/navidrome:0.0.1"}, self.to))
|
||||
self.assertEqual(rc, 1); self.assertIn("the box walk started FROM", out)
|
||||
|
||||
def test_refuses_a_digest_that_moved_since_the_walk(self):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to, digest="sha256:" + "9" * 64))
|
||||
self.assertEqual(rc, 1); self.assertIn("walk again", out)
|
||||
|
||||
def test_refuses_a_database_engine_major(self):
|
||||
dc = os.path.join(self.tmp, "templates", "docmost", "docker-compose.yml")
|
||||
frm = ladder.images_in(open(dc).read())
|
||||
to = dict(frm); to["docmost-postgres"] = "postgres:19-alpine"
|
||||
self.assertEqual(frm["docmost-postgres"].split(":")[1].split("-")[0], "18") # READ: the live engine major
|
||||
rc, out = self.run_sec(box_walk_record("docmost", frm, to))
|
||||
self.assertEqual(rc, 1); self.assertIn("may not cross a database engine major", out)
|
||||
|
||||
def test_refuses_a_missing_field_and_a_bad_id(self):
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to), drop=("--advisory",))
|
||||
self.assertEqual(rc, 1); self.assertIn("['--advisory']", out)
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to), over={"--ids": "OSV-2026-1"})
|
||||
self.assertEqual(rc, 1); self.assertIn("are not CVE-YYYY-NNNN or GHSA", out)
|
||||
rc, out = self.run_sec(box_walk_record("navidrome", self.frm, self.to, seed=None))
|
||||
self.assertEqual(rc, 1); self.assertIn("seed is None", out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
@@ -409,15 +409,18 @@ class BoxWalkTargets(unittest.TestCase):
|
||||
sys.modules.pop("box_walk", None)
|
||||
return importlib.import_module("box_walk")
|
||||
|
||||
# 9202 takes its address by DHCP (.114 until 2026-10-19, then .121), so its row names none and box_walk reads it from
|
||||
# the guest at start (resolve_base). These tests pass BASE so the import asks no box (2026-10-23: they pinned .114).
|
||||
def test_every_row_is_complete(self):
|
||||
bw = self.load({})
|
||||
bw = self.load({"BASE": "https://192.0.2.1"})
|
||||
for name, row in bw.TARGETS.items():
|
||||
self.assertEqual(set(row), {"hp", "ssh", "jump", "guest", "base", "domain"}, name)
|
||||
self.assertTrue(row["base"].startswith("https://"), name)
|
||||
self.assertTrue(row["base"] is None or row["base"].startswith("https://"), name)
|
||||
self.assertIsNone(bw.TARGETS["9202"]["base"], "9202 is DHCP: its address is read from the guest, never typed")
|
||||
|
||||
def test_the_default_stays_scratch_9202(self):
|
||||
bw = self.load({})
|
||||
self.assertEqual((bw.HP, bw.GUEST, bw.BASE), ("demo-hp", "9202", "https://192.168.0.114"))
|
||||
bw = self.load({"BASE": "https://192.0.2.1"})
|
||||
self.assertEqual((bw.HP, bw.GUEST, bw.BASE), ("demo-hp", "9202", "https://192.0.2.1"))
|
||||
self.assertEqual(bw.ssh_args()[-1], "demo-hp")
|
||||
self.assertNotIn("-J", bw.ssh_args())
|
||||
|
||||
|
||||
+102
-1
@@ -1254,6 +1254,8 @@ def write_ladder(argv) -> int:
|
||||
import datetime as _dt
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import ladder, image_digest
|
||||
if "--security" in argv:
|
||||
return write_security_step(argv)
|
||||
|
||||
def arg(name, default=None):
|
||||
return argv[argv.index(name) + 1] if name in argv else default
|
||||
@@ -1339,6 +1341,17 @@ def write_ladder(argv) -> int:
|
||||
if probs:
|
||||
print(f"REFUSED {app}: the entry would not be well-formed: {probs}")
|
||||
return 1
|
||||
return apply_entry(app, tdir, comp, cur, bfrom, bto, entry, conv, retest, peak, digests, arg("--to-definition"))
|
||||
|
||||
|
||||
def apply_entry(app, tdir, comp, cur, bfrom, bto, entry, conv, retest, peak, digests, todef):
|
||||
"""The writer's one tail, shared by every step kind (proven, re-test, security_fix — D39 = B reuses it, never forks
|
||||
it): keep the superseded step's own definition, move the compose (or write the definition step), set
|
||||
`catalog_since`, append the entry."""
|
||||
import datetime as _dt
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import ladder
|
||||
comp_p, fy_p = tdir / "docker-compose.yml", tdir / ".felhom.yml"
|
||||
# `09` §6.4 part 5: the step being SUPERSEDED keeps its own definition. When the ladder's head is the
|
||||
# compose as it stands, that compose — the head's images with every fix that flowed since — becomes
|
||||
# steps/<step_key(head.to)>.yml, the file a box one step behind will pin (check-test-record.py rule 4).
|
||||
@@ -1353,7 +1366,6 @@ def write_ladder(argv) -> int:
|
||||
if not smp.exists(): # R-664: and its own .felhom.yml, without the ladder
|
||||
smp.write_text(ladder.strip_ladder_block(fy_p.read_text(encoding="utf-8")))
|
||||
print(f"STEP {app}: … and its .felhom.yml at {ladder.step_meta_file(cur)}")
|
||||
todef = arg("--to-definition")
|
||||
if todef:
|
||||
# R-762: a definition step (a new service): the TO compose is that definition as a whole, and its images must
|
||||
# be exactly what the bench tested TO. Never a hand edit — the file the bench ran is the file written.
|
||||
@@ -1390,6 +1402,95 @@ def write_ladder(argv) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
SECURITY_VALUE_FLAGS = ("--ids", "--advisory", "--fixed-in", "--box", "--box-evidence", "--catalog", "--evidence")
|
||||
|
||||
|
||||
def write_security_step(argv) -> int:
|
||||
"""`--write-ladder --security --ids <id,…> --advisory <url> --fixed-in <v> --box <box.json> --box-evidence <rel>
|
||||
--catalog <checkout> [<bench.json> --evidence <rel>]` — the writer of a SECURITY-FIX step (`09` §3 decision 255,
|
||||
D39 = B). The box walk (`box_walk.py --security`) is the required venue; a bench run is optional and, when given,
|
||||
must be proven. It refuses: the box not proven; a bench given and not proven, or naming another edge; the template
|
||||
not at the box walk's FROM; a digest that moved since the walk; a database engine major; a field the entry needs.
|
||||
The rest — the superseded step's own definition, the compose move, `catalog_since`, the append — is apply_entry,
|
||||
the one tail every step kind shares."""
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import ladder, image_digest
|
||||
|
||||
def arg(name, default=None):
|
||||
return argv[argv.index(name) + 1] if name in argv and argv.index(name) + 1 < len(argv) else default
|
||||
values = {argv[i + 1] for i, a in enumerate(argv) if a in SECURITY_VALUE_FLAGS and i + 1 < len(argv)}
|
||||
positional = [a for a in argv if not a.startswith("--") and a not in values]
|
||||
need = {"--ids": arg("--ids"), "--advisory": arg("--advisory"), "--fixed-in": arg("--fixed-in"),
|
||||
"--box": arg("--box"), "--box-evidence": arg("--box-evidence"), "--catalog": arg("--catalog")}
|
||||
missing = sorted(k for k, v in need.items() if not v)
|
||||
if missing:
|
||||
print(f"REFUSED: a security-fix step needs {missing}")
|
||||
return 1
|
||||
box = json.loads(Path(need["--box"]).read_text(encoding="utf-8"))
|
||||
app = box.get("app")
|
||||
if box.get("walk") != "security" or box.get("verdict") != "proven":
|
||||
print(f"REFUSED {app}: the box walk is {box.get('walk')!r} with verdict {box.get('verdict')!r} — only a PROVEN "
|
||||
"`box_walk.py --security` walk is written as a security-fix step")
|
||||
return 1
|
||||
bench = json.loads(Path(positional[0]).read_text(encoding="utf-8")) if positional else None
|
||||
bfrom, bto = plain_refs(box.get("from")), plain_refs(box.get("to"))
|
||||
if bench is not None:
|
||||
if bench.get("verdict") != "proven" or (bench.get("harness_version") or 0) < 2 or not arg("--evidence"):
|
||||
print(f"REFUSED {app}: a bench run was given with verdict {bench.get('verdict')!r} (harness "
|
||||
f"{bench.get('harness_version')!r}, evidence {arg('--evidence')!r}) — a bench given must be PROVEN, "
|
||||
"with the memory watch and its evidence path")
|
||||
return 1
|
||||
if plain_refs(bench.get("from")) != bfrom or plain_refs(bench.get("to")) != bto:
|
||||
print(f"REFUSED {app}: the bench tested {bench.get('from')} -> {bench.get('to')}, the box walked {bfrom} -> {bto}")
|
||||
return 1
|
||||
tdir = Path(need["--catalog"]) / "templates" / app
|
||||
comp = (tdir / "docker-compose.yml").read_text(encoding="utf-8")
|
||||
cur = ladder.images_in(comp)
|
||||
if cur != bfrom:
|
||||
print(f"REFUSED {app}: the template is at {cur}, the box walk started FROM {bfrom}")
|
||||
return 1
|
||||
crossed = ladder.engine_majors_crossed(bfrom, bto)
|
||||
if crossed:
|
||||
print(f"REFUSED {app}: a security-fix step may not cross a database engine major: {crossed}")
|
||||
return 1
|
||||
digests = {}
|
||||
walked = box.get("to_digests") or {}
|
||||
for svc, ref in sorted(bto.items()):
|
||||
d, why = image_digest.resolve(ref)
|
||||
if not d:
|
||||
print(f"INCONCLUSIVE {app}: {svc} {ref}: {why}")
|
||||
return 2
|
||||
if walked.get(svc) != d:
|
||||
print(f"REFUSED {app}: {svc} {ref}: the box walk ran {str(walked.get(svc))[:19]}, the registry serves "
|
||||
f"{d[:19]} now — the image that was walked is not the image a box would pull; walk again")
|
||||
return 1
|
||||
digests[svc] = d
|
||||
peak = (box.get("memory") or {}).get("peak_pct")
|
||||
if not isinstance(peak, (int, float)) or isinstance(peak, bool):
|
||||
print(f"REFUSED {app}: the box walk recorded no memory soak peak")
|
||||
return 1
|
||||
marks = set((bench or {}).get("marks") or [])
|
||||
entry = {"from": bfrom, "to": bto, "digest": digests, "verdict": ladder.SECURITY_FIX,
|
||||
"tested_at": box["measured_at"],
|
||||
"harness_version": bench["harness_version"] if bench else None,
|
||||
"evidence": arg("--evidence") if bench else None,
|
||||
"box_evidence": need["--box-evidence"],
|
||||
"memory_peak_pct": peak, "memory_basis": "box_soak",
|
||||
# files_may_change is a BENCH measurement; with no bench the step says false and decision 255 says why
|
||||
"marks": {"files_may_change": "files_may_change" in marks, "needs_person": None,
|
||||
"memory_tight": peak > ladder.MEMORY_TIGHT_PCT},
|
||||
"security": {"ids": [i.strip() for i in need["--ids"].split(",") if i.strip()],
|
||||
"advisory": need["--advisory"], "fixed_in": need["--fixed-in"]},
|
||||
"seed": box.get("seed")}
|
||||
if bench:
|
||||
entry["bench_verdict"] = bench["verdict"]
|
||||
probs = ladder.check_entry(entry)
|
||||
if probs:
|
||||
print(f"REFUSED {app}: the entry would not be well-formed: {probs}")
|
||||
return 1
|
||||
return apply_entry(app, tdir, comp, cur, bfrom, bto, entry, None, False, peak, digests, None)
|
||||
|
||||
|
||||
def write_restep(argv) -> int:
|
||||
"""`--restep <bench verdict.json> --definition <dir> --catalog <checkout> --evidence <rel>` — rewrite ONE
|
||||
superseded step's own definition (`steps/<key>.yml` + `steps/<key>.felhom.yml`) from a bench re-proof of THAT
|
||||
|
||||
Reference in new issue
Block a user