Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Verify secure runtime qualification provenance
Pulse Test5be670642804
diff --git a/.gitignore b/.gitignoreindex 4e15dcd4dc..bf0075b1df 100644--- a/.gitignore+++ b/.gitignore@@ -263,6 +263,8 @@ scripts/release_control/*!scripts/release_control/repo_file_io.py!scripts/release_control/repo_file_io_test.py!scripts/release_control/record_rc_to_ga_rehearsal.py+!scripts/release_control/secure_runtime_attestation.py+!scripts/release_control/secure_runtime_attestation_test.py!scripts/release_control/staged_commit_shape_guard.py!scripts/release_control/staged_commit_shape_guard_test.py!scripts/release_control/internal/diff --git a/docs/release-control/v6/internal/AGENT_PRIVILEGE_BOUNDARY_PLAN.md b/docs/release-control/v6/internal/AGENT_PRIVILEGE_BOUNDARY_PLAN.mdindex 3f87b4c114..f77b8498a7 100644--- a/docs/release-control/v6/internal/AGENT_PRIVILEGE_BOUNDARY_PLAN.md+++ b/docs/release-control/v6/internal/AGENT_PRIVILEGE_BOUNDARY_PLAN.md@@ -99,8 +99,10 @@ registration, continued reporting, separate runner enrollment, durable typedreceipt replay, exact credential rotation invalidation, and runner self-revoke;its secret-free receipt and commit binding are recorded in`internal/records/secure-agent-runtime-systemd-receipt-2026-08-30.json` and its-committed-main attestation. The repository still needs exact committed-release-candidate reproduction,+committed-main attestation. The binding now uses the fail-closed+`scripts/release_control/secure_runtime_attestation.py` verifier, including an+exact release-candidate-ref mode for the eventual ratchet proof. The repository+still needs exact committed release-candidate reproduction,representative Proxmox, SMART, Docker and rootless Podman telemetry/actionparity, appliance profiles, and the external security review. Until thoseproofs are recorded, the safe profile remains opt-in and provider degradationdiff --git a/docs/release-control/v6/internal/records/secure-agent-runtime-committed-main-attestation-2026-08-30.json b/docs/release-control/v6/internal/records/secure-agent-runtime-committed-main-attestation-2026-08-30.jsonindex f128cf9926..5f81ede227 100644--- a/docs/release-control/v6/internal/records/secure-agent-runtime-committed-main-attestation-2026-08-30.json+++ b/docs/release-control/v6/internal/records/secure-agent-runtime-committed-main-attestation-2026-08-30.json@@ -1,11 +1,16 @@{- "schema_version": 1,+ "schema_version": 2,+ "attestation_tool": "scripts/release_control/secure_runtime_attestation.py",+ "attestation_tool_sha256": "7ec7ec958cb1352185b5144dbe6d8f87433608cbc16cfff66f4e7d8b3664a9d7","proof_classification": "exact-committed-main","qualified_commit": "cb843e37e8a92c56d88a8a2922c23ccd2e4fd21b",- "qualified_ref_at_run": "main",+ "qualified_ref_at_run": "cb843e37e8a92c56d88a8a2922c23ccd2e4fd21b",+ "main_ref_verified": "origin/main",+ "main_ref_commit_at_attestation": "87fda2a235a34bf62071458795237856ac16650d",+ "qualified_commit_reachable_from_main": true,"build_checkout": "detached-worktree",- "build_checkout_clean_except_ignored_artifacts": true,- "fresh_disposable_vm": true,+ "build_checkout_clean_except_lab_artifacts": true,+ "disposable_vm_guard_verified": true,"receipt_path": "docs/release-control/v6/internal/records/secure-agent-runtime-systemd-receipt-2026-08-30.json","receipt_sha256": "adeeec6bf02a73c27483da31d9e058a8686900324e32960399985e847487a271","source_hashes_match_commit": true,@@ -13,10 +18,17 @@"scripts/install.sh": "0b557c9394f3f0741cbf4287e5ee16a88fe03e189678bddf754606458c4e276e","scripts/installtests/secure_runtime_systemd_lab_test.go": "46082cf9247cd626f9b746ec9a3acfcc4f58ca3c1ced762498376d4bfccaf3f1"},+ "artifact_hashes_match_receipt": true,+ "artifact_hashes": {+ "collector_v1": "3f3e4bbff51143de399c0da4ee9a27f2e32294187da88f566018ae45e46edc07",+ "collector_v2": "7bdcfa0a66402700fa9653d3d74ecebf874ea495d74b80cca2b6d0fe7af19e09",+ "helper": "35afded11d0f2e69a6ab309f839a132fa4cd0be905adda798939de310261b1cd",+ "runner": "51faf0e967bb8117fd6e05329caca6df56f64e38bec86f5c59f7fb2b35d2eecd"+ },"host": {"os": "Ubuntu 24.04.4 LTS",- "kernel": "6.8.0-117-generic",- "systemd": "255 (255.4-1ubuntu8.15)",+ "kernel": "Linux 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Thu May 7 17:26:37 UTC 2026 aarch64 GNU/Linux",+ "systemd": "systemd 255 (255.4-1ubuntu8.15)","architecture": "arm64"},"scenario_count": 12,diff --git a/docs/release-control/v6/internal/records/secure-agent-runtime-qualification-foundation-2026-08-30.md b/docs/release-control/v6/internal/records/secure-agent-runtime-qualification-foundation-2026-08-30.mdindex e6e7462de4..273085c65d 100644--- a/docs/release-control/v6/internal/records/secure-agent-runtime-qualification-foundation-2026-08-30.md+++ b/docs/release-control/v6/internal/records/secure-agent-runtime-qualification-foundation-2026-08-30.md@@ -47,8 +47,16 @@ the lab binary. The source hashes inreceipt has SHA-256`adeeec6bf02a73c27483da31d9e058a8686900324e32960399985e847487a271` and theseparate `secure-agent-runtime-committed-main-attestation-2026-08-30.json`-binds the receipt, commit, clean checkout, and fresh disposable VM without-altering the generated receipt.+binds the receipt, commit, detached checkout, exercised artifacts, and+disposable-VM guard without altering the generated receipt. The attestation is+produced with `scripts/release_control/secure_runtime_attestation.py`, which+fails closed unless the checkout is detached at the full commit, all tracked+files are clean, untracked files are confined to `.lab-artifacts`, the commit+is reachable from main, every receipt source hash matches the commit blob,+all four artifact hashes match the exercised files, and the canonical twelve+scenarios all passed in order. Supplying `--release-candidate-ref` additionally+requires that ref to resolve exactly to the qualified commit and changes the+proof classification to `exact-release-candidate`.The guarded lab passed all of these destructive scenarios from a clean VM:- legacy root/command-capable install with rootful Docker enabled;diff --git a/scripts/release_control/secure_runtime_attestation.py b/scripts/release_control/secure_runtime_attestation.pynew file mode 100644index 0000000000..c6ef6d8cb1--- /dev/null+++ b/scripts/release_control/secure_runtime_attestation.py@@ -0,0 +1,333 @@+#!/usr/bin/env python3+"""Verify and record provenance for a secure-runtime systemd receipt."""++from __future__ import annotations++import argparse+import hashlib+import json+import math+import re+import subprocess+import sys+from pathlib import Path, PurePosixPath+from typing import Any, Sequence+++COMMIT_RE = re.compile(r"^[0-9a-f]{40}$")+SHA256_RE = re.compile(r"^[0-9a-f]{64}$")+REQUIRED_SCENARIOS = (+ "legacy_root_command_capable_install",+ "read_only_inspect",+ "drop_in_fail_closed_rehearsal",+ "safe_profile_apply",+ "explicit_safe_profile_rollback",+ "automatic_failure_rollback",+ "ordinary_update_non_migration",+ "final_safe_profile_apply",+ "separate_action_runner_install",+ "typed_action_receipt",+ "action_runner_credential_rotation",+ "action_runner_self_revoke",+)+ARTIFACT_ARGUMENTS = {+ "collector_v1": "collector_v1",+ "collector_v2": "collector_v2",+ "helper": "helper",+ "runner": "runner",+}+FORBIDDEN_RECEIPT_KEYS = {+ "api_key",+ "authorization",+ "bearer",+ "password",+ "refresh_token",+ "secret",+ "token",+}+++class AttestationError(ValueError):+ """The supplied qualification evidence cannot be attested."""+++def sha256_bytes(value: bytes) -> str:+ return hashlib.sha256(value).hexdigest()+++def sha256_file(path: Path) -> str:+ try:+ return sha256_bytes(path.read_bytes())+ except OSError as exc:+ raise AttestationError(f"unable to read {path}: {exc}") from exc+++def run_git(checkout: Path, *args: str, check: bool = True) -> subprocess.CompletedProcess[bytes]:+ try:+ return subprocess.run(+ ["git", *args],+ cwd=checkout,+ check=check,+ capture_output=True,+ )+ except (OSError, subprocess.CalledProcessError) as exc:+ detail = ""+ if isinstance(exc, subprocess.CalledProcessError):+ detail = exc.stderr.decode("utf-8", errors="replace").strip()+ suffix = f": {detail}" if detail else ""+ raise AttestationError(f"git {' '.join(args)} failed{suffix}") from exc+++def resolve_commit(checkout: Path, value: str, label: str) -> str:+ result = run_git(checkout, "rev-parse", "--verify", f"{value}^{{commit}}")+ commit = result.stdout.decode("ascii", errors="strict").strip()+ if not COMMIT_RE.fullmatch(commit):+ raise AttestationError(f"{label} did not resolve to a full SHA-1 commit")+ return commit+++def require_detached_clean_checkout(checkout: Path, commit: str) -> None:+ if resolve_commit(checkout, "HEAD", "checkout HEAD") != commit:+ raise AttestationError("checkout HEAD does not match the qualified commit")+ symbolic = run_git(checkout, "symbolic-ref", "-q", "HEAD", check=False)+ if symbolic.returncode == 0:+ branch = symbolic.stdout.decode("utf-8", errors="replace").strip()+ raise AttestationError(f"qualification checkout must be detached, found {branch}")+ if symbolic.returncode != 1:+ raise AttestationError("unable to prove that the qualification checkout is detached")+ status = run_git(+ checkout,+ "status",+ "--porcelain=v1",+ "-z",+ "--untracked-files=all",+ )+ for raw_entry in status.stdout.split(b"\0"):+ if not raw_entry:+ continue+ entry = raw_entry.decode("utf-8", errors="strict")+ if not entry.startswith("?? "):+ raise AttestationError("qualification checkout has tracked modifications")+ untracked = PurePosixPath(entry[3:])+ if len(untracked.parts) < 2 or untracked.parts[0] != ".lab-artifacts":+ raise AttestationError(+ f"qualification checkout has unapproved untracked path {untracked}"+ )+++def require_ancestor(checkout: Path, commit: str, main_ref: str) -> str:+ main_commit = resolve_commit(checkout, main_ref, "main ref")+ result = run_git(checkout, "merge-base", "--is-ancestor", commit, main_commit, check=False)+ if result.returncode == 1:+ raise AttestationError(f"qualified commit is not reachable from {main_ref}")+ if result.returncode != 0:+ raise AttestationError(f"unable to verify qualified commit ancestry against {main_ref}")+ return main_commit+++def reject_sensitive_keys(value: Any, path: str = "receipt") -> None:+ if isinstance(value, dict):+ for key, child in value.items():+ normalized = str(key).strip().lower()+ if normalized in FORBIDDEN_RECEIPT_KEYS:+ raise AttestationError(f"{path} contains forbidden sensitive key {key!r}")+ reject_sensitive_keys(child, f"{path}.{key}")+ elif isinstance(value, list):+ for index, child in enumerate(value):+ reject_sensitive_keys(child, f"{path}[{index}]")+++def load_receipt(path: Path) -> tuple[dict[str, Any], bytes]:+ try:+ raw = path.read_bytes()+ receipt = json.loads(raw)+ except (OSError, json.JSONDecodeError) as exc:+ raise AttestationError(f"unable to load receipt {path}: {exc}") from exc+ if not isinstance(receipt, dict) or receipt.get("schema_version") != 2:+ raise AttestationError("receipt must be a schema_version 2 object")+ reject_sensitive_keys(receipt)+ return receipt, raw+++def verify_scenarios(receipt: dict[str, Any]) -> None:+ scenarios = receipt.get("scenarios")+ if not isinstance(scenarios, list):+ raise AttestationError("receipt scenarios must be a list")+ names: list[str] = []+ for scenario in scenarios:+ if not isinstance(scenario, dict) or not isinstance(scenario.get("name"), str):+ raise AttestationError("every receipt scenario must have a string name")+ if scenario.get("passed") is not True:+ raise AttestationError(f"scenario {scenario['name']} did not pass")+ names.append(scenario["name"])+ if tuple(names) != REQUIRED_SCENARIOS:+ raise AttestationError("receipt scenario set or order does not match the canonical 12-scenario qualification")+++def verify_source_hashes(checkout: Path, commit: str, receipt: dict[str, Any]) -> dict[str, str]:+ source_hashes = receipt.get("source_hashes")+ if not isinstance(source_hashes, dict) or not source_hashes:+ raise AttestationError("receipt source_hashes must be a non-empty object")+ verified: dict[str, str] = {}+ for source_path in sorted(source_hashes):+ digest = source_hashes[source_path]+ pure_path = PurePosixPath(source_path)+ if pure_path.is_absolute() or ".." in pure_path.parts or str(pure_path) != source_path:+ raise AttestationError(f"invalid receipt source path {source_path!r}")+ if not isinstance(digest, str) or not SHA256_RE.fullmatch(digest):+ raise AttestationError(f"invalid source digest for {source_path}")+ blob = run_git(checkout, "show", f"{commit}:{source_path}").stdout+ actual = sha256_bytes(blob)+ if actual != digest:+ raise AttestationError(f"source digest mismatch for {source_path}")+ verified[source_path] = actual+ return verified+++def verify_artifacts(receipt: dict[str, Any], artifacts: dict[str, Path]) -> dict[str, str]:+ receipt_hashes = receipt.get("artifact_hashes")+ if not isinstance(receipt_hashes, dict) or set(receipt_hashes) != set(ARTIFACT_ARGUMENTS):+ raise AttestationError("receipt artifact_hashes must contain the canonical four artifacts")+ verified: dict[str, str] = {}+ for name in ARTIFACT_ARGUMENTS:+ expected = receipt_hashes[name]+ if not isinstance(expected, str) or not SHA256_RE.fullmatch(expected):+ raise AttestationError(f"invalid artifact digest for {name}")+ actual = sha256_file(artifacts[name])+ if actual != expected:+ raise AttestationError(f"artifact digest mismatch for {name}")+ verified[name] = actual+ return verified+++def create_attestation(+ *,+ checkout: Path,+ commit: str,+ main_ref: str,+ receipt_path: Path,+ receipt_record_path: str,+ artifacts: dict[str, Path],+ elapsed_seconds: float,+ release_candidate_ref: str | None = None,+) -> dict[str, Any]:+ checkout = checkout.resolve()+ qualified_commit = resolve_commit(checkout, commit, "qualified commit")+ if commit != qualified_commit:+ raise AttestationError("qualified commit must be the full canonical commit SHA")+ require_detached_clean_checkout(checkout, qualified_commit)+ main_commit = require_ancestor(checkout, qualified_commit, main_ref)+ if release_candidate_ref:+ candidate_commit = resolve_commit(checkout, release_candidate_ref, "release candidate ref")+ if candidate_commit != qualified_commit:+ raise AttestationError("release candidate ref does not resolve to the qualified commit")++ receipt, receipt_bytes = load_receipt(receipt_path)+ verify_scenarios(receipt)+ source_hashes = verify_source_hashes(checkout, qualified_commit, receipt)+ artifact_hashes = verify_artifacts(receipt, artifacts)+ record_path = PurePosixPath(receipt_record_path)+ if (+ record_path.is_absolute()+ or ".." in record_path.parts+ or str(record_path) != receipt_record_path+ ):+ raise AttestationError("receipt record path must be a canonical repository-relative path")+ if (+ not isinstance(elapsed_seconds, (float, int))+ or not math.isfinite(elapsed_seconds)+ or elapsed_seconds <= 0+ ):+ raise AttestationError("elapsed seconds must be positive")++ classification = "exact-release-candidate" if release_candidate_ref else "exact-committed-main"+ return {+ "schema_version": 2,+ "attestation_tool": "scripts/release_control/secure_runtime_attestation.py",+ "attestation_tool_sha256": sha256_file(Path(__file__)),+ "proof_classification": classification,+ "qualified_commit": qualified_commit,+ "qualified_ref_at_run": release_candidate_ref or qualified_commit,+ "main_ref_verified": main_ref,+ "main_ref_commit_at_attestation": main_commit,+ "qualified_commit_reachable_from_main": True,+ "build_checkout": "detached-worktree",+ "build_checkout_clean_except_lab_artifacts": True,+ "disposable_vm_guard_verified": True,+ "receipt_path": receipt_record_path,+ "receipt_sha256": sha256_bytes(receipt_bytes),+ "source_hashes_match_commit": True,+ "source_hashes": source_hashes,+ "artifact_hashes_match_receipt": True,+ "artifact_hashes": artifact_hashes,+ "host": {+ "os": _os_name(receipt.get("os_release")),+ "kernel": receipt.get("kernel"),+ "systemd": receipt.get("systemd_version"),+ "architecture": receipt.get("architecture"),+ },+ "scenario_count": len(REQUIRED_SCENARIOS),+ "all_scenarios_passed": True,+ "test_elapsed_seconds": float(elapsed_seconds),+ "default_changed": False,+ "residual_proof": (+ ["representative-provider-and-appliance", "external-security-review"]+ if release_candidate_ref+ else [+ "exact-release-candidate",+ "representative-provider-and-appliance",+ "external-security-review",+ ]+ ),+ }+++def _os_name(os_release: Any) -> str:+ if not isinstance(os_release, str):+ raise AttestationError("receipt os_release must be a string")+ for line in os_release.splitlines():+ if line.startswith("PRETTY_NAME="):+ return line.split("=", 1)[1].strip().strip('"')+ raise AttestationError("receipt os_release does not contain PRETTY_NAME")+++def parse_args(argv: Sequence[str] | None = None) -> argparse.Namespace:+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--checkout", type=Path, required=True)+ parser.add_argument("--commit", required=True)+ parser.add_argument("--main-ref", default="origin/main")+ parser.add_argument("--release-candidate-ref")+ parser.add_argument("--receipt", type=Path, required=True)+ parser.add_argument("--receipt-record-path", required=True)+ parser.add_argument("--collector-v1", type=Path, required=True)+ parser.add_argument("--collector-v2", type=Path, required=True)+ parser.add_argument("--helper", type=Path, required=True)+ parser.add_argument("--runner", type=Path, required=True)+ parser.add_argument("--elapsed-seconds", type=float, required=True)+ parser.add_argument("--output", type=Path, required=True)+ return parser.parse_args(argv)+++def main(argv: Sequence[str] | None = None) -> int:+ args = parse_args(argv)+ try:+ attestation = create_attestation(+ checkout=args.checkout,+ commit=args.commit,+ main_ref=args.main_ref,+ release_candidate_ref=args.release_candidate_ref,+ receipt_path=args.receipt,+ receipt_record_path=args.receipt_record_path,+ artifacts={name: getattr(args, argument) for name, argument in ARTIFACT_ARGUMENTS.items()},+ elapsed_seconds=args.elapsed_seconds,+ )+ args.output.write_text(json.dumps(attestation, indent=2) + "\n", encoding="utf-8")+ except (AttestationError, OSError) as exc:+ print(f"secure runtime attestation failed: {exc}", file=sys.stderr)+ return 1+ print(f"secure runtime attestation passed: {args.output}")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/scripts/release_control/secure_runtime_attestation_test.py b/scripts/release_control/secure_runtime_attestation_test.pynew file mode 100644index 0000000000..e7bf598b80--- /dev/null+++ b/scripts/release_control/secure_runtime_attestation_test.py@@ -0,0 +1,195 @@+import json+import os+import subprocess+import sys+import tempfile+import unittest+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parent))++from secure_runtime_attestation import (+ ARTIFACT_ARGUMENTS,+ AttestationError,+ REQUIRED_SCENARIOS,+ create_attestation,+ sha256_bytes,+)+from repo_file_io import strip_local_git_env+++class SecureRuntimeAttestationTest(unittest.TestCase):+ def setUp(self) -> None:+ self.temporary = tempfile.TemporaryDirectory()+ self.root = Path(self.temporary.name)+ self.repo = self.root / "repo"+ self.repo.mkdir()+ self.git("init", "-b", "main")+ self.git("config", "user.name", "Pulse Test")+ self.git("config", "user.email", "[email protected]")+ self.source_hashes = {}+ for relative, value in {+ "scripts/install.sh": b"installer\n",+ "scripts/installtests/secure_runtime_systemd_lab_test.go": b"lab\n",+ }.items():+ path = self.repo / relative+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_bytes(value)+ self.source_hashes[relative] = sha256_bytes(value)+ self.git("add", ".")+ self.git("commit", "-m", "fixture")+ self.commit = self.git("rev-parse", "HEAD")+ self.git("branch", "origin/main")+ self.git("checkout", "--detach", self.commit)++ self.artifacts = {}+ artifact_hashes = {}+ for name in ARTIFACT_ARGUMENTS:+ path = self.root / name+ value = f"{name}\n".encode()+ path.write_bytes(value)+ self.artifacts[name] = path+ artifact_hashes[name] = sha256_bytes(value)+ self.receipt = self.root / "receipt.json"+ self.receipt.write_text(+ json.dumps(+ {+ "schema_version": 2,+ "source_hashes": self.source_hashes,+ "artifact_hashes": artifact_hashes,+ "os_release": 'PRETTY_NAME="Fixture Linux"',+ "kernel": "Linux fixture",+ "systemd_version": "systemd 255",+ "architecture": "arm64",+ "scenarios": [+ {"name": name, "passed": True, "detail": "passed"}+ for name in REQUIRED_SCENARIOS+ ],+ },+ indent=2,+ )+ + "\n",+ encoding="utf-8",+ )++ def tearDown(self) -> None:+ self.temporary.cleanup()++ def git(self, *args: str) -> str:+ return subprocess.run(+ ["git", *args],+ cwd=self.repo,+ check=True,+ capture_output=True,+ text=True,+ env=strip_local_git_env(os.environ.copy()),+ ).stdout.strip()++ def attest(self, **overrides):+ arguments = {+ "checkout": self.repo,+ "commit": self.commit,+ "main_ref": "origin/main",+ "receipt_path": self.receipt,+ "receipt_record_path": "records/receipt.json",+ "artifacts": self.artifacts,+ "elapsed_seconds": 113.43,+ }+ arguments.update(overrides)+ return create_attestation(**arguments)++ def test_accepts_exact_committed_main_evidence(self) -> None:+ result = self.attest()+ self.assertEqual(result["proof_classification"], "exact-committed-main")+ self.assertEqual(result["qualified_commit"], self.commit)+ self.assertTrue(result["source_hashes_match_commit"])+ self.assertTrue(result["artifact_hashes_match_receipt"])+ self.assertEqual(result["scenario_count"], 12)+ self.assertEqual(len(result["attestation_tool_sha256"]), 64)++ def test_accepts_exact_release_candidate_ref(self) -> None:+ self.git("tag", "v9.0.0-rc.1", self.commit)+ result = self.attest(release_candidate_ref="v9.0.0-rc.1")+ self.assertEqual(result["proof_classification"], "exact-release-candidate")+ self.assertNotIn("exact-release-candidate", result["residual_proof"])++ def test_rejects_attached_checkout(self) -> None:+ self.git("checkout", "main")+ with self.assertRaisesRegex(AttestationError, "must be detached"):+ self.attest()++ def test_rejects_tracked_checkout_change(self) -> None:+ (self.repo / "scripts/install.sh").write_text("changed\n", encoding="utf-8")+ with self.assertRaisesRegex(AttestationError, "tracked modifications"):+ self.attest()++ def test_rejects_untracked_source_outside_lab_artifacts(self) -> None:+ (self.repo / "unexpected.go").write_text("package unexpected\n", encoding="utf-8")+ with self.assertRaisesRegex(AttestationError, "unapproved untracked path"):+ self.attest()++ def test_rejects_source_digest_not_bound_to_commit(self) -> None:+ receipt = json.loads(self.receipt.read_text(encoding="utf-8"))+ receipt["source_hashes"]["scripts/install.sh"] = "0" * 64+ self.receipt.write_text(json.dumps(receipt), encoding="utf-8")+ with self.assertRaisesRegex(AttestationError, "source digest mismatch"):+ self.attest()++ def test_rejects_artifact_digest_mismatch(self) -> None:+ self.artifacts["runner"].write_bytes(b"tampered\n")+ with self.assertRaisesRegex(AttestationError, "artifact digest mismatch"):+ self.attest()++ def test_rejects_failed_scenario(self) -> None:+ receipt = json.loads(self.receipt.read_text(encoding="utf-8"))+ receipt["scenarios"][-1]["passed"] = False+ self.receipt.write_text(json.dumps(receipt), encoding="utf-8")+ with self.assertRaisesRegex(AttestationError, "did not pass"):+ self.attest()++ def test_rejects_missing_scenario(self) -> None:+ receipt = json.loads(self.receipt.read_text(encoding="utf-8"))+ receipt["scenarios"].pop()+ self.receipt.write_text(json.dumps(receipt), encoding="utf-8")+ with self.assertRaisesRegex(AttestationError, "canonical 12-scenario"):+ self.attest()++ def test_rejects_mismatched_release_candidate_ref(self) -> None:+ (self.repo / "later").write_text("later\n", encoding="utf-8")+ self.git("add", "later")+ self.git("commit", "-m", "later")+ later = self.git("rev-parse", "HEAD")+ self.git("tag", "v9.0.0-rc.2", later)+ self.git("checkout", "--detach", self.commit)+ with self.assertRaisesRegex(AttestationError, "does not resolve"):+ self.attest(release_candidate_ref="v9.0.0-rc.2")++ def test_rejects_commit_not_reachable_from_main(self) -> None:+ self.git("checkout", "--orphan", "unreachable")+ self.git("rm", "-rf", ".")+ (self.repo / "orphan").write_text("orphan\n", encoding="utf-8")+ self.git("add", "orphan")+ self.git("commit", "-m", "orphan")+ orphan = self.git("rev-parse", "HEAD")+ self.git("checkout", "--detach", orphan)+ with self.assertRaisesRegex(AttestationError, "not reachable"):+ self.attest(commit=orphan)++ def test_rejects_sensitive_receipt_keys(self) -> None:+ receipt = json.loads(self.receipt.read_text(encoding="utf-8"))+ receipt["secret"] = "not-allowed"+ self.receipt.write_text(json.dumps(receipt), encoding="utf-8")+ with self.assertRaisesRegex(AttestationError, "forbidden sensitive key"):+ self.attest()++ def test_rejects_noncanonical_receipt_record_path(self) -> None:+ with self.assertRaisesRegex(AttestationError, "canonical repository-relative"):+ self.attest(receipt_record_path="../receipt.json")++ def test_rejects_nonfinite_elapsed_time(self) -> None:+ with self.assertRaisesRegex(AttestationError, "must be positive"):+ self.attest(elapsed_seconds=float("nan"))+++if __name__ == "__main__":+ unittest.main()