Harden runtime distribution acceptance
This commit is contained in:
@@ -3,7 +3,9 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -26,9 +28,32 @@ FINALIZE = _load(
|
||||
"finalize_runtime_distribution",
|
||||
ROOT / "tools/release/finalize-runtime-distribution.py",
|
||||
)
|
||||
DEPLOYER_BUILD = _load(
|
||||
"build_deployer_zipapp",
|
||||
ROOT / "tools/deployment/build-deployer-zipapp.py",
|
||||
)
|
||||
|
||||
|
||||
class RuntimeDistributionBuildTests(unittest.TestCase):
|
||||
def test_deployment_zipapp_is_reproducible_across_source_mtimes(self) -> None:
|
||||
with tempfile.TemporaryDirectory(prefix="govoplan-reproducible-zipapp-") as value:
|
||||
root = Path(value)
|
||||
source = root / "source"
|
||||
shutil.copytree(ROOT / "tools/deployment", source)
|
||||
first = root / "first.pyz"
|
||||
second = root / "second.pyz"
|
||||
original_root = DEPLOYER_BUILD.ROOT
|
||||
try:
|
||||
DEPLOYER_BUILD.ROOT = source
|
||||
self.assertEqual(0, DEPLOYER_BUILD.main(["--output", str(first)]))
|
||||
for path in source.rglob("*.py"):
|
||||
os.utime(path, (2_000_000_000, 2_000_000_000))
|
||||
self.assertEqual(0, DEPLOYER_BUILD.main(["--output", str(second)]))
|
||||
finally:
|
||||
DEPLOYER_BUILD.ROOT = original_root
|
||||
|
||||
self.assertEqual(first.read_bytes(), second.read_bytes())
|
||||
|
||||
def test_workflow_signs_with_the_release_environment(self) -> None:
|
||||
workflow = (ROOT / ".gitea/workflows/runtime-distribution.yml").read_text(
|
||||
encoding="utf-8"
|
||||
@@ -43,6 +68,35 @@ class RuntimeDistributionBuildTests(unittest.TestCase):
|
||||
workflow,
|
||||
)
|
||||
|
||||
def test_workflow_verifies_portable_bootstrap_artifacts_before_execution(
|
||||
self,
|
||||
) -> None:
|
||||
workflow = (ROOT / ".gitea/workflows/runtime-distribution.yml").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
"(cd runtime-output && sha256sum govoplan-deploy.pyz > "
|
||||
"govoplan-deploy.pyz.sha256)",
|
||||
workflow,
|
||||
)
|
||||
self.assertIn("openssl pkeyutl -verify -pubin", workflow)
|
||||
self.assertIn("govoplan-deploy.tampered.pyz", workflow)
|
||||
self.assertLess(
|
||||
workflow.index("openssl pkeyutl -verify -pubin"),
|
||||
workflow.index("python runtime-output/govoplan-deploy.pyz init"),
|
||||
)
|
||||
|
||||
def test_workflow_retains_both_platform_runtime_smoke_receipts(self) -> None:
|
||||
workflow = (ROOT / ".gitea/workflows/runtime-distribution.yml").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
self.assertIn('for ARCH in amd64 arm64; do', workflow)
|
||||
self.assertIn("tools/checks/runtime-image-smoke.py", workflow)
|
||||
self.assertIn("runtime-smoke-amd64.json", workflow)
|
||||
self.assertIn("runtime-smoke-arm64.json", workflow)
|
||||
|
||||
def test_resolves_platforms_and_builds_evidence_descriptor(self) -> None:
|
||||
index = {
|
||||
"schemaVersion": 2,
|
||||
|
||||
Reference in New Issue
Block a user