Files
mtusi2026lab7/scripts/verify_security.py
T

59 lines
1.7 KiB
Python

"""Prepare public/negative fixtures and run the operator-only matrix probe."""
import argparse
import json
from datetime import UTC, datetime
from scripts.bootstrap_security import (
SECRET,
key_bytes,
make_root,
public,
sign_leaf,
write_private,
)
from scripts.stand import ROOT, command, compose
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--output", default="evidence/security-first.json")
args = parser.parse_args()
output = ROOT / args.output
assert not output.exists(), "Choose a new receipt path"
fixture = SECRET / "probe"
fixture.mkdir(mode=0o755, exist_ok=True)
root_key, root_cert = make_root()
key, leaf = sign_leaf(root_key, root_cert, "lb", ["lb"])
write_private(fixture / "foreign-ca.pem", public(root_cert), mode=0o644)
write_private(
fixture / "foreign/cert.pem",
public(leaf) + public(root_cert),
mode=0o644,
)
write_private(fixture / "foreign/key.pem", key_bytes(key), mode=0o644)
result = json.loads(
compose(
"--profile",
"operator",
"run",
"--rm",
"--no-deps",
"operator-probe",
)
)
result.update(
date=datetime.now(UTC).isoformat(),
source_commit=command(["git", "rev-parse", "HEAD"]),
)
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n")
assert result["complete"]
print(
"PASS: real mTLS identities, server CA/hostname, closed plaintext boundaries and worker least privilege"
)
if __name__ == "__main__":
main()