Files
felhom.eu/documentation/audits/new-apps-2026-10-01/tools/boxprep.py
T
2026-10-01 18:01:40 +02:00

24 lines
1.3 KiB
Python

"""boxprep.py <app> <sub> — the BOX venue's first half on 9202 (drill catalog): deploy through the product, seed through
the app's own route, read it back (C1). The seed tokens (and the deploy secrets this run generated) go to the 0600 file in
SC so boxstep.py can read the app back. Evidence: box/<app>/prep.txt. (From more-night-apps-2026-09-30/tools/boxmove.py.)"""
import json, os, sys, time
import walk as w
sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts")
import upgrade_fixtures_box as fixtures, upgrade_fixtures_box28 as _f28
FX = dict(_f28.FIXTURES28); FX.update(fixtures.FIXTURES)
app, sub = sys.argv[1:3]
EVD = f"{w.EV}/box/{app}"; os.makedirs(EVD, exist_ok=True)
TOK = w.SC + "/seed-tokens-box.json"
log = open(f"{EVD}/prep.txt", "a", buffering=1)
def say(*a):
w.say(*a); log.write(" ".join(map(str, a)) + "\n")
w.login()
toks = json.load(open(TOK)) if os.path.exists(TOK) else {}
t0 = time.time()
say(f"deploy {app}: {w.deploy(app, sub)} ({round(time.time()-t0)} s)")
toks[app] = FX[app].seed(w, sub, say)
if isinstance(toks[app], dict) and w.GENERATED.get(app):
toks[app]["__generated"] = w.GENERATED[app]
json.dump(toks, open(TOK, "w"), default=str); os.chmod(TOK, 0o600)
say(f"C1 seed reads back BEFORE: {FX[app].verify(w, sub, toks[app], say) if toks[app] else 'NO SEED: ' + str(getattr(FX[app], 'tried', ''))}")