Files
felhom.eu/documentation/audits/release-2026-10-26/tools/homepage_gate.py
T

23 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""homepage_gate.py — D46 on the drill catalog (9202): Homepage deployed with `family_gate: true` stops a stranger
(no cookie → a redirect to /__family/start) and lets the household in (dashboard session → felhom_famgate → 200).
The same household pass on the same box is the positive control. Removed through the product at the end."""
import os, re, sys, time
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../catalog-sweep-2026-10-24/tools"))
os.environ.setdefault("TARGET", "9202")
import box_walk as w
APP = SUB = "homepage"
w.login()
try:
ok = w.deploy(APP, SUB) and w.wait_app(SUB, "/", tries=60, delay=5)
w.say(f"deployed: {ok}, state={w.stack(APP).get('state')}")
for accept in ("text/html", "application/json"):
r = w.sh(["curl", "-sk", "-D", "-", "-o", "/dev/null", "-H", f"Accept: {accept}", "-H", f"Host: {SUB}.{w.DOMAIN}", f"{w.BASE}/"])
st = re.match(r"HTTP/\S+ (\d+)", r.stdout or "")
w.say(f"STRANGER ({accept}): {st.group(1) if st else '?'} location={w._loc(r.stdout)[:90]}")
rc, code, body = w.app_curl(SUB, "/")
w.say(f"HOUSEHOLD (dashboard session -> family cookie): {code}, body {len(body)} B, homepage marker={'homepage' in body.lower()}")
finally:
w.remove(APP)