Files
felhom.eu/documentation/audits/version-travel-2026-09-26/tools/sr.py
T

20 lines
917 B
Python

"""sr.py seed|read <label> app=sub[,app=sub] — seed or read back through each app's OWN front door (fixtures.py).
Tokens stay in the scratchpad; the evidence gets True/False only."""
import json, sys, os
import walk as w, fixtures
mode, label = sys.argv[1], sys.argv[2]
SUBS = dict(x.split("=") for x in sys.argv[3].split(","))
TOK = w.SC + "/seed-tokens.json"
w.login()
toks = json.load(open(TOK)) if os.path.exists(TOK) else {}
res = {}
for a, sub in SUBS.items():
if mode == "seed":
toks[a] = fixtures.FIXTURES[a].seed(w, sub, w.say); res[a] = toks[a] is not None
else:
res[a] = bool(toks.get(a)) and fixtures.FIXTURES[a].verify(w, sub, toks[a], w.say)
if mode == "seed":
json.dump(toks, open(TOK, "w"), default=str); os.chmod(TOK, 0o600)
line = f"{label}: {mode} " + " ".join(f"{a}={v}" for a, v in res.items())
w.say(line); open(w.EV + "/data-readback.txt", "a").write(line + "\n")