From b131d3c4cc32e4bd45765dc4f403107f9370a483 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 21:22:50 +0100 Subject: [PATCH] Bind signed release seeds to verified source archives --- tests/FEED.md | 4 +++- tests/release-inputs.py | 6 ++++-- tools/release-inputs.py | 12 ++++++++---- tools/stage-image.py | 22 ++++++++++++++++++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/tests/FEED.md b/tests/FEED.md index aeee538..b3dea89 100644 --- a/tests/FEED.md +++ b/tests/FEED.md @@ -183,13 +183,15 @@ For Vinix's release driver with `--ports-inputs` support, prepare one directory ```sh python3 tools/release-inputs.py "$arch" "$repo" "$desktop_client" "$desktop_x11_client" \ "$native_layer" "$auditor" "$release_inputs/$release_arch" \ - "$fingerprint" "$vinix_commit" "$release_tag" + "$fingerprint" "$vinix_commit" "$release_tag" --archive-coverage "$coverage" ``` Use `amd64` or `arm64` for `release_arch`. The tool checks the native desktop and login ELF targets, rejects collisions with files from either installed client, requires the signed seed to contain the installed versions from both clients, and adds the release tag to the initramfs. It writes the initramfs, X11 overlay, build info and checksum files together. The ISO driver checks the checksums and build info against its selected release before building the kernel. `python3 tests/release-inputs.py` covers the output format and wrong-architecture rejection. The worker also confirmed the tag in a signed test initramfs and rejected a second client requiring a package missing from the signed seed. See `foundation/ports-release-inputs-contract-02`, receipt SHA-256 `75e7b4ae23a4f0ea27f93dfd740d37d1ed3abc4cfbea906ec957186c65a1e543`. +The candidate uses `--archive-coverage` with the complete scan from `tools/release-archives.py`. The stage tool matches the version, archive name and digest from the signed index to a verified source archive for every seeded package. The worker staged three exact packages on each target, rejected a correctly signed older x86_64 musl archive, and rejected an AArch64 musl digest mismatch. Both failures stopped before exposing an initramfs. See `foundation/ports-seed-archive-proof-02`, receipt SHA-256 `6cbe4c5c50067e318e182c0a5b936b51cf1760cc0aaa1672a9e570d12da9afc0`. + The AArch64 sidecar preflight used the release driver's SDK extraction list and a signed Vinix musl and GCC SDK to build the static iOS runner from Vinix commit `01665ff6`. The worker reused the cross-compiled mbed TLS archive for the final link. The runner's four ELF load segments passed the 16 KiB congruence check, and `qemu-aarch64` ran `run-ios --help`. See `foundation/ports-candidate-ios-sdk-01`, receipt SHA-256 `b5130a6c933a169dfbd3951e3f015be9bbefd6143f368c7e8813f2e3ee3f83ba`. The candidate release worktree built and linked both Vinix kernels with the Makefile from `6e4cb463`, using two compile jobs. The worker checked the two ELF machine types and hashed both binaries before ISO assembly. See `foundation/ports-candidate-kernels-01`, receipt SHA-256 `deef1918e5124396283aa9ac23ca1e0f8e461d2618d878b7da46b812d463e9b2`. diff --git a/tests/release-inputs.py b/tests/release-inputs.py index 5ed9e8a..8fc45f3 100644 --- a/tests/release-inputs.py +++ b/tests/release-inputs.py @@ -22,7 +22,8 @@ class ReleaseInputs(unittest.TestCase): self.args = argparse.Namespace( arch="aarch64", native=root / "native", output=root / "arm64", release="iso-fixture", commit="a" * 40, repo=root / "repo", desktop=root / "desktop", - graphics=root / "graphics", auditor=root / "audit", fingerprint="a" * 40) + graphics=root / "graphics", auditor=root / "audit", fingerprint="a" * 40, + archive_coverage=root / "coverage.tsv") for name in ("bin/vinix-desktop", "sbin/vinix-session", "sbin/vinix-authd", "sbin/vinix-system", "sbin/vinix-account"): path = self.args.native / "usr" / name @@ -45,7 +46,8 @@ class ReleaseInputs(unittest.TestCase): else: self.assertEqual(argv[1].name, "stage-image.py") self.assertIn("--release=iso-fixture", argv) - self.assertEqual(argv[-2:], ["--seed-client", self.args.graphics]) + self.assertEqual(argv[-4:], ["--seed-client", self.args.graphics, + "--archive-coverage", self.args.archive_coverage]) argv[5].mkdir() (argv[5] / names[0]).write_bytes(b"initramfs") diff --git a/tools/release-inputs.py b/tools/release-inputs.py index 84a7211..9c03913 100644 --- a/tools/release-inputs.py +++ b/tools/release-inputs.py @@ -38,10 +38,13 @@ def assemble(args): stage = work / "image" subprocess.run([sys.executable, tools / "bundle-x11.py", args.arch, args.desktop, args.graphics, args.auditor, bundle], check=True) - subprocess.run([sys.executable, tools / "stage-image.py", args.arch, args.desktop, - args.repo, stage, args.auditor, args.fingerprint, "--native-layer", - args.native, "--initramfs", f"--release={args.release}", - "--seed-client", args.graphics], check=True) + command = [sys.executable, tools / "stage-image.py", args.arch, args.desktop, + args.repo, stage, args.auditor, args.fingerprint, "--native-layer", + args.native, "--initramfs", f"--release={args.release}", + "--seed-client", args.graphics] + if args.archive_coverage: + command.extend(["--archive-coverage", args.archive_coverage]) + subprocess.run(command, check=True) (stage / "initramfs.tar").rename(bundle / "initramfs.tar") info = bundle / "build-info" info.write_text(f"commit={args.commit}\nrelease={args.release}\narch={arch}\n") @@ -61,4 +64,5 @@ if __name__ == "__main__": parser.add_argument(name, type=lambda path: Path(path).absolute()) for name in ("fingerprint", "commit", "release"): parser.add_argument(name) + parser.add_argument("--archive-coverage", type=Path, help="verified archive inventory for the signed seed") assemble(parser.parse_args()) diff --git a/tools/stage-image.py b/tools/stage-image.py index af79b38..309f694 100644 --- a/tools/stage-image.py +++ b/tools/stage-image.py @@ -100,7 +100,21 @@ def install_native_layer(source, root, table, seed_roots=()): walk(source, root) -def snapshot(repo, dest, ring, arch, gpg_home): +def verified_archives(coverage): + verified = {} + seen = set() + with coverage.open() as stream: + for row in csv.DictReader(stream, delimiter="\t"): + name = row["package"] + if name in seen: + raise ValueError(f"duplicate archive coverage for {name}") + seen.add(name) + if row["status"] == "verified": + verified[name] = (row["version"], Path(row["archive"]).name, row["archive_sha256"]) + return verified + + +def snapshot(repo, dest, ring, arch, gpg_home, coverage=None): def verify(path): subprocess.run(["gpgv", "--homedir", gpg_home, "--keyring", ring, str(path) + ".sig", path], check=True, stdout=subprocess.DEVNULL) @@ -133,6 +147,8 @@ def snapshot(repo, dest, ring, arch, gpg_home): if (name in indexed or package_arch not in (arch, "any") or filename != f"{name}-{version}-{package_arch}.pkg.tar.zst"): raise ValueError(f"invalid database record for {name}") + if coverage is not None and coverage.get(name) != (version, filename, info["SHA256SUM"]): + raise ValueError(f"signed seed package differs from verified release archives: {name}") archive = copy(filename) copy(filename + ".sig") with archive.open("rb") as stream: @@ -153,6 +169,7 @@ def stage(args): raise ValueError("put image output outside its input directories") if native and not native.is_dir(): raise ValueError("expected a staging directory for the native layer") + coverage = verified_archives(args.archive_coverage) if args.archive_coverage else None output.mkdir() audit = subprocess.check_output([args.auditor, args.arch, client], text=True) (output / "audited-root.log").write_text(audit) @@ -168,7 +185,7 @@ def stage(args): raise ValueError("seed repository directory is already populated") with tempfile.TemporaryDirectory() as gpg_home: indexed = snapshot(repo / args.arch, package_dir, root / "usr/share/vpac/keyrings/vinix.gpg", - args.arch, gpg_home) + args.arch, gpg_home, coverage) records = client / "db/local" for database in [records, *(root / "db/local" for root in args.seed_client)]: descriptions = sorted(database.glob("*/desc")) @@ -222,5 +239,6 @@ if __name__ == "__main__": parser.add_argument("--release", default="", help="release tag stored in /etc/vinix-release") parser.add_argument("--seed-client", type=Path, action="append", default=[], help="require the installed versions from another audited client in the seed") + parser.add_argument("--archive-coverage", type=Path, help="match signed seed packages to verified release archives") parser.add_argument("--initramfs", action="store_true", help="write a root-owned USTAR archive for the ISO builder") stage(parser.parse_args()) -- 2.56.1