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
+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