up
Some checks failed
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Policy Simulation / policy-simulate (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Some checks failed
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Policy Simulation / policy-simulate (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
REQUIRED_FILES: tuple[str, ...] = (
|
||||
"attestation.dsse.json",
|
||||
"callgraph.framework.json",
|
||||
"callgraph.static.json",
|
||||
"reachgraph.truth.json",
|
||||
"sbom.cdx.json",
|
||||
"sbom.spdx.json",
|
||||
"symbols.json",
|
||||
"vex.openvex.json",
|
||||
)
|
||||
|
||||
|
||||
def _sha256_hex(path: Path) -> str:
|
||||
digest = hashlib.sha256()
|
||||
with path.open("rb") as handle:
|
||||
for chunk in iter(lambda: handle.read(1024 * 1024), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def _locate_repo_root(start: Path) -> Path:
|
||||
current = start.resolve()
|
||||
while True:
|
||||
if (current / "Directory.Build.props").is_file():
|
||||
return current
|
||||
if current.parent == current:
|
||||
raise RuntimeError("Cannot locate repo root (missing Directory.Build.props).")
|
||||
current = current.parent
|
||||
|
||||
|
||||
def _update_manifest(variant_dir: Path) -> bool:
|
||||
manifest_path = variant_dir / "manifest.json"
|
||||
if not manifest_path.is_file():
|
||||
return False
|
||||
|
||||
with manifest_path.open("r", encoding="utf-8") as handle:
|
||||
manifest = json.load(handle)
|
||||
|
||||
files: dict[str, str] = dict(manifest.get("files") or {})
|
||||
|
||||
for required in REQUIRED_FILES:
|
||||
required_path = variant_dir / required
|
||||
if not required_path.is_file():
|
||||
raise FileNotFoundError(f"Missing required fixture file: {required_path}")
|
||||
|
||||
files[required] = _sha256_hex(required_path)
|
||||
|
||||
manifest["files"] = files
|
||||
|
||||
with manifest_path.open("w", encoding="utf-8", newline="\n") as handle:
|
||||
json.dump(manifest, handle, indent=2, ensure_ascii=False)
|
||||
handle.write("\n")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def main() -> int:
|
||||
repo_root = _locate_repo_root(Path(__file__).parent)
|
||||
cases_root = repo_root / "tests" / "reachability" / "fixtures" / "reachbench-2025-expanded" / "cases"
|
||||
|
||||
updated = 0
|
||||
for case_dir in sorted([p for p in cases_root.iterdir() if p.is_dir()], key=lambda p: p.name):
|
||||
images = case_dir / "images"
|
||||
for variant_name in ("reachable", "unreachable"):
|
||||
variant_dir = images / variant_name
|
||||
if _update_manifest(variant_dir):
|
||||
updated += 1
|
||||
|
||||
print(f"Updated {updated} variant manifests under {cases_root}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
Reference in New Issue
Block a user