81 lines
3.6 KiB
Python
81 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Validate Phase-1.0AW against exact RetroArch and shsrv Git objects."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def git(repo: Path, *args: str) -> str:
|
|
return subprocess.run(["git", *args], cwd=repo, check=True,
|
|
capture_output=True, text=True).stdout.strip()
|
|
|
|
|
|
def check(repo: Path, commit: str, path: str, blob: str, size: int) -> None:
|
|
spec = f"{commit}:{path}"
|
|
assert git(repo, "rev-parse", spec) == blob
|
|
assert int(git(repo, "cat-file", "-s", spec)) == size
|
|
|
|
|
|
def show(repo: Path, commit: str, path: str) -> str:
|
|
return git(repo, "show", f"{commit}:{path}")
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--root", type=Path, required=True)
|
|
parser.add_argument("--retroarch-root", type=Path, required=True)
|
|
parser.add_argument("--shsrv-root", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
root = args.root
|
|
path = root / "manifests/retroarch/phase-1.0aw-canary-source-delta-audit.json"
|
|
data = json.loads(path.read_text(encoding="utf-8"))
|
|
b = data["source_bindings"]
|
|
av = root / "manifests/retroarch/phase-1.0av-launch-context-canary-contract.json"
|
|
assert hashlib.sha256(av.read_bytes()).hexdigest() == b["phase10av_manifest_sha256"]
|
|
retroarch_paths = {
|
|
"retroarch_c": "retroarch.c", "sdl2_gfx": "gfx/drivers/sdl2_gfx.c",
|
|
"platform_smoke_c": "frontend/drivers/platform_ps5_smoke.c",
|
|
"platform_smoke_h": "frontend/drivers/platform_ps5_smoke.h",
|
|
"diag_c": "pkg/ps5/chimera_ps5_diag.c",
|
|
"diag_h": "pkg/ps5/chimera_ps5_diag.h",
|
|
"stream_c": "pkg/ps5/chimera_ps5_diag_stream.c",
|
|
"stream_h": "pkg/ps5/chimera_ps5_diag_stream.h",
|
|
"makefile": "Makefile.ps5",
|
|
"sdl_hardening_patch": "pkg/ps5/sdl2-ps5-smoke-hardening.patch",
|
|
}
|
|
for prefix, source in retroarch_paths.items():
|
|
check(args.retroarch_root, b["retroarch_commit"], source,
|
|
b[f"{prefix}_blob"], b[f"{prefix}_size"])
|
|
shsrv_paths = {"v07_hbldr": "bundles/hbldr/main.c",
|
|
"v07_elfldr": "elfldr.c", "v07_shell": "sh.c",
|
|
"v07_service": "shsrv.c"}
|
|
for prefix, source in shsrv_paths.items():
|
|
check(args.shsrv_root, b["shsrv_v07_commit"], source,
|
|
b[f"{prefix}_blob"], b[f"{prefix}_size"])
|
|
retroarch_c = show(args.retroarch_root, b["retroarch_commit"], "retroarch.c")
|
|
diag_c = show(args.retroarch_root, b["retroarch_commit"], "pkg/ps5/chimera_ps5_diag.c")
|
|
hbldr = show(args.shsrv_root, b["shsrv_v07_commit"], "bundles/hbldr/main.c")
|
|
elfldr = show(args.shsrv_root, b["shsrv_v07_commit"], "elfldr.c")
|
|
assert "main_exit(data);" in retroarch_c and "_Exit(result);" in retroarch_c
|
|
assert "CHIMERA_PS5_DIAG_D12" in diag_c and "CHIMERA_PS5_DIAG_FRAME_TERMINAL" in diag_c
|
|
assert "elfldr_exec(STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO" in hbldr
|
|
assert "stdout_fd = pt_rdup(pid, getpid(), stdout_fd);" in elfldr
|
|
assert "while(1)" in hbldr and "sceSystemServiceKillApp" in hbldr
|
|
assert data["historical_payload"]["reusable_as_av_canary"] is False
|
|
assert data["required_payload_source_delta"]["new_cleanup_failure_counter_required"] is True
|
|
assert data["bigapp_result_path"]["live_result_path_proven"] is False
|
|
assert not any(data["authorizations"].values())
|
|
assert data["decision"]["target_artifact_build_allowed"] is False
|
|
print("Phase-1.0AW canary source-delta audit validation passed")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|