"""Which stages does each control touch? Compares a few control bundles."""
import json
chain = json.load(open("data/attack_chain.json"))["stages"]
CONTROLS = ["email_filtering", "mfa", "patching", "edr", "least_privilege", "segmentation", "egress_filtering", "logging_alerts", "offline_backups"]

def touched(bundle):
    return [s["n"] for s in chain if set(s["controls"]) & set(bundle)]

if __name__ == "__main__":
    print("== stages touched per single control (of 12)")
    for c in CONTROLS:
        t = touched([c]); print(f"  {c:<17} {len(t):>2}  stages {t}")
    bundles = {
        "backups only":                       ["offline_backups"],
        "backups + patching + segmentation":  ["offline_backups", "patching", "segmentation"],
        "big three + MFA + EDR":              ["offline_backups", "patching", "segmentation", "mfa", "edr"],
        "everything":                         CONTROLS,
    }
    print("\n== bundles")
    for name, b in bundles.items():
        t = touched(b); missed = [s["n"] for s in chain if s["n"] not in t]
        print(f"  {name:<36} touches {len(t):>2}/12   exfil stage (10) {'covered' if 10 in t else 'NOT covered':<11} untouched: {missed}")
