23 lines
1.5 KiB
Python
23 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify the bounded security-surface repair against its pre-edit source baseline."""
|
|
from pathlib import Path
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
|
|
ROOT = Path(__file__).resolve().parents[4]
|
|
BASELINE = "ef1609f52398dfa2f1ba0acf83f298df0c6b7fe4"
|
|
PREFIX = "src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/"
|
|
HELPER = ' private readonly string _fieldScope = "ot-role-grants-" + Guid.NewGuid().ToString("N");\n private string FieldId(string suffix) => _fieldScope + "-" + suffix;\n'
|
|
files = []
|
|
for name in ("RoleGrants.razor", "Certificates.razor"):
|
|
relative = PREFIX + name
|
|
before = subprocess.check_output(["git", "show", BASELINE + ":" + relative], cwd=ROOT).decode()
|
|
after = (ROOT / relative).read_text()
|
|
normalized = after.replace(HELPER, "", 1) if name == "RoleGrants.razor" else after
|
|
assert before.split("@code {", 1)[1] == normalized.split("@code {", 1)[1], relative
|
|
files.append({"file": relative, "beforeSha256": hashlib.sha256(before.encode()).hexdigest(), "afterSha256": hashlib.sha256(after.encode()).hexdigest(), "existingCodeBodyExact": True})
|
|
result = {"baseline": BASELINE, "files": files, "roleOnlyAdditiveCode": HELPER, "scope": "Labels, persistent error association and local wrapping/shrinkability only; no mutation/query/auth/bind/event changes"}
|
|
Path(__file__).with_name("source-parity.json").write_text(json.dumps(result, indent=2) + "\n")
|
|
print("Two existing code bodies unchanged; only additive RoleGrants ID helper allowed.")
|