From 28736d0c66f7169539c90e4d7493abee47c5a845 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Mon, 16 Nov 2026 00:39:57 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20publish=20oci=20layout=20to?= =?UTF-8?q?=20avoid=20rootless=20archive=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skopeo's oci-archive transport restores tar ownership, which fails for rootless container runs. Materializing the verified archive as a temporary OCI layout avoids ownership restoration while preserving the same bytes and digests. Tests cover the layout publish path, cleanup after failure, and the local container mount for oci: sources. --- tests/oci.Tests.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tools/oci.py | 47 +++++++++++++++++++++++------------- 2 files changed, 91 insertions(+), 16 deletions(-) diff --git a/tests/oci.Tests.py b/tests/oci.Tests.py index f6516d9..40cc370 100644 --- a/tests/oci.Tests.py +++ b/tests/oci.Tests.py @@ -210,8 +210,68 @@ def test_latest_alias_is_rejected_before_any_registry_upload(self): oci.publish(self.args) transfer.assert_not_called() + def test_publish_uses_owner_independent_layout_and_preserves_verified_bytes(self): + amd, _, _ = self.fixture('amd64') + arm, _, _ = self.fixture('arm64') + self.args.archive = str(self.root / 'combined.tar') + self.args.inputs = [str(amd), str(arm)] + self.args.tags = ['docker.io/fork/csrun:11.0.100', 'docker.io/fork/csrun:11'] + oci.merge(self.args) + original = oci.checksum(self.args.archive) + archive = oci.Archive(self.args.archive) + layouts = [] + + def transfer(arguments, *, capture=False): + if arguments[0] == 'inspect': + return oci.encoded(archive.index) + self.assertEqual(arguments[:3], ['copy', '--all', '--preserve-digests']) + if arguments[3].startswith('docker://'): + shutil.copyfile(self.args.archive, arguments[4].removeprefix('oci-archive:')) + return + self.assertTrue(arguments[3].startswith('oci:')) + layout = Path(arguments[3].removeprefix('oci:')) + layouts.append(layout) + self.assertEqual({p.relative_to(layout).as_posix() for p in layout.rglob('*') if p.is_file()}, set(archive.members)) + for name, member in archive.members.items(): + with archive.tar.extractfile(member) as source: + self.assertEqual((layout / name).read_bytes(), source.read()) + + with patch.object(oci, 'skopeo', side_effect=transfer), patch.object(oci.tarfile.TarFile, 'chown', side_effect=PermissionError('ownership restoration forbidden')): + oci.publish(self.args) + archive.tar.close() + self.assertEqual(len(layouts), 2) + self.assertEqual(layouts[0], layouts[1]) + self.assertFalse(layouts[0].exists()) + self.assertEqual(original, oci.checksum(self.args.archive)) + self.assertEqual(len(json.loads(Path(self.args.archive + '.published.json').read_text())), 2) + + def test_publish_removes_temporary_layout_after_transfer_failure(self): + path, _, _ = self.fixture('amd64') + self.args.archive = str(path) + self.args.platform = 'amd64' + self.args.tags = ['docker.io/fork/csrun:11'] + layouts = [] + + def fail_transfer(arguments): + layouts.append(Path(arguments[3].removeprefix('oci:'))) + self.assertTrue(layouts[-1].is_dir()) + raise RuntimeError('transfer failed') + + with patch.object(oci, 'skopeo', side_effect=fail_transfer): + with self.assertRaisesRegex(RuntimeError, 'transfer failed'): + oci.publish(self.args) + self.assertFalse(layouts[0].exists()) + self.assertFalse(Path(str(path) + '.published.json').exists()) + class SkopeoTransportTests(unittest.TestCase): + def test_local_container_mounts_oci_layout_directory(self): + with patch.dict('os.environ', {'DOCKER_HOST': 'unix:///var/run/docker.sock'}, clear=True), patch.object(oci.shutil, 'which', return_value=None), patch.object(oci.subprocess, 'run') as execute: + oci.skopeo(['copy', '--all', '--preserve-digests', 'oci:client-layout', 'docker://registry/image:11']) + command = execute.call_args.args[0] + self.assertIn('oci:/archive3/client-layout', command) + self.assertIn(str(Path('client-layout').resolve().parent) + ':/archive3', command) + def test_native_skopeo_does_not_need_a_local_docker_daemon(self): with patch.dict('os.environ', {'DOCKER_HOST': 'ssh://builder'}, clear=True), patch.object(oci.shutil, 'which', return_value='/usr/bin/skopeo'), patch.object(oci.subprocess, 'run') as execute, patch.object(oci.subprocess, 'check_output') as inspect: oci.skopeo(['copy', 'oci-archive:client.tar', 'docker://registry/image:11']) diff --git a/tools/oci.py b/tools/oci.py index a8fcc64..4b137c7 100644 --- a/tools/oci.py +++ b/tools/oci.py @@ -1,5 +1,6 @@ """Verify, assemble and promote csrun OCI content without rebuilding it (stdlib only).""" import argparse +import contextlib import hashlib import json import os @@ -59,6 +60,17 @@ def blob(self, descriptor): require(name in self.members and self.members[name].size == descriptor['size'], 'Missing or truncated OCI content') return self.read(name) + @contextlib.contextmanager + def layout(self): + """Materialize verified files without restoring tar ownership or modes.""" + with tempfile.TemporaryDirectory() as temp: + for name, member in self.members.items(): + target = Path(temp) / name + target.parent.mkdir(parents=True, exist_ok=True) + with self.tar.extractfile(member) as source, target.open('wb') as output: + shutil.copyfileobj(source, output) + yield temp + def verify(self, args, platforms): runnable = [d for d in self.index['manifests'] if d.get('platform', {}).get('os') == 'linux'] actual = [d['platform']['architecture'] for d in runnable] @@ -164,11 +176,12 @@ def skopeo(arguments, *, capture=False): command = ['docker', 'run', '--rm', '--user', '0'] converted = [] for position, argument in enumerate(arguments): - if argument.startswith('oci-archive:'): - path = Path(argument[len('oci-archive:'):]).resolve() + if argument.startswith(('oci-archive:', 'oci:')): + transport, local_path = argument.split(':', 1) + path = Path(local_path).resolve() mount = '/archive' + str(position) command.extend(['--volume', str(path.parent) + ':' + mount]) - argument = 'oci-archive:' + mount + '/' + path.name + argument = transport + ':' + mount + '/' + path.name converted.append(argument) auth = os.environ.get('REGISTRY_AUTH_FILE') if auth: @@ -250,19 +263,21 @@ def publish(args): require(args.tags and len({t.rsplit(':', 1)[0] for t in args.tags}) == 1, 'SDK aliases must target one repository') for tag in args.tags: require(re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9._:/-]*:[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}', tag) and tag.rsplit(':', 1)[1] != 'latest', 'Invalid publishing destination') - for tag in args.tags: - skopeo(['copy', '--all', '--preserve-digests', 'oci-archive:' + args.archive, 'docker://' + tag]) - raw = skopeo(['inspect', '--raw', 'docker://' + tag], capture=True) - index = json.loads(raw) - require({d['digest'] for d in index['manifests']} == expected, 'Registry platform/attestation identities changed') - digest = 'sha256:' + hashlib.sha256(raw).hexdigest() - digests.add(digest) - with tempfile.TemporaryDirectory() as temp: - downloaded = str(Path(temp) / 'registry.tar') - skopeo(['copy', '--all', '--preserve-digests', 'docker://' + tag.rsplit(':', 1)[0] + '@' + digest, 'oci-archive:' + downloaded]) - Archive(downloaded).verify(args, [args.platform] if getattr(args, 'platform', None) else ['amd64', 'arm64']) - print(tag + '@' + digest) - published.append({'tag': tag, 'digest': digest}) + # Skopeo's archive transport restores tar ownership, which fails rootless. + with archive.layout() as layout: + for tag in args.tags: + skopeo(['copy', '--all', '--preserve-digests', 'oci:' + layout, 'docker://' + tag]) + raw = skopeo(['inspect', '--raw', 'docker://' + tag], capture=True) + index = json.loads(raw) + require({d['digest'] for d in index['manifests']} == expected, 'Registry platform/attestation identities changed') + digest = 'sha256:' + hashlib.sha256(raw).hexdigest() + digests.add(digest) + with tempfile.TemporaryDirectory() as temp: + downloaded = str(Path(temp) / 'registry.tar') + skopeo(['copy', '--all', '--preserve-digests', 'docker://' + tag.rsplit(':', 1)[0] + '@' + digest, 'oci-archive:' + downloaded]) + Archive(downloaded).verify(args, [args.platform] if getattr(args, 'platform', None) else ['amd64', 'arm64']) + print(tag + '@' + digest) + published.append({'tag': tag, 'digest': digest}) require(len(digests) == 1, 'SDK aliases resolved to different indexes') Path(str(args.archive) + '.published.json').write_bytes(encoded(published)) summary = os.environ.get('GITHUB_STEP_SUMMARY') From adddfe71126075e8695df1ecf46c36e719283036 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Mon, 16 Nov 2026 00:40:12 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=91=B7=20promote=20all=20sdk=20varian?= =?UTF-8?q?ts=20in=20one=20deploy=20job?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Promotion previously ran as a matrix of separate jobs, each needing its own approval. A single Production approval now covers all three SDK variants. The job promotes them sequentially, attempts every variant even if one fails, and fails overall if any promotion fails. The job timeout is raised to fit the combined run. --- .github/workflows/deploy.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6b3ad0e..02314a2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,19 +67,14 @@ jobs: run: python tools/release-images.py restore "$SDK_VARIANT" publish: - name: Promote SDK ${{ matrix.sdk }} to Docker Hub + name: Promote all SDK images to Docker Hub needs: [resolve, verify] runs-on: ubuntu-26.04 - timeout-minutes: 60 + timeout-minutes: 180 environment: Production permissions: contents: read actions: read - strategy: - fail-fast: false - max-parallel: 1 - matrix: - sdk: ['10', '11', '10-11'] steps: - uses: codebeltnet/git-checkout@v1 with: @@ -88,11 +83,6 @@ jobs: with: name: resolved-release path: resolved - - name: Restore exact verified release artifact - env: - GH_TOKEN: ${{ github.token }} - SDK_VARIANT: ${{ matrix.sdk }} - run: python tools/release-images.py restore "$SDK_VARIANT" - name: Install OCI transfer tool run: sudo apt-get update && sudo apt-get install -y --no-install-recommends skopeo - name: Authenticate, promote without rebuild and inspect registry content @@ -105,4 +95,15 @@ jobs: export REGISTRY_AUTH_FILE="$RUNNER_TEMP/csrun-auth.json" trap 'rm -f "$REGISTRY_AUTH_FILE"' EXIT printf '%s' "$DOCKERHUB_TOKEN" | skopeo login --authfile "$REGISTRY_AUTH_FILE" --username "$DOCKERHUB_USERNAME" --password-stdin docker.io - python tools/release-images.py publish + status=0 + for sdk in 10 11 10-11; do + echo "::group::Promote SDK $sdk" + if python tools/release-images.py restore "$sdk" && python tools/release-images.py publish; then + echo "SDK $sdk promotion succeeded." + else + echo "::error::SDK $sdk promotion failed." + status=1 + fi + echo "::endgroup::" + done + exit "$status" From 49506f5929fed002de0a2dfe269dd194d110acb2 Mon Sep 17 00:00:00 2001 From: aicia-bot Date: Mon, 16 Nov 2026 00:40:14 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20document=20single=20approval?= =?UTF-8?q?=20for=20sdk=20promotion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The release flow description still implied separate approvals per SDK variant. It now states that one Production approval covers all three variants and that each is attempted even if another fails. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37a5aa2..b09dd2e 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ Release delivery follows these stages: 2. Assembly combines the unchanged AMD64/ARM64 manifests and attestations into one index per SDK environment. `codebeltnet/oci-artifact-verify@v1` checks the checksum, released source identity and multi-platform contract; csrun also validates all blobs, config labels, native result records, SBOM and provenance. No layers are rebuilt. 3. The established release job creates a **draft GitHub Release** containing the tested standalone engine, its checksum, release records and tested OCI artifacts. Archives are split into 1 GiB assets to stay below GitHub's per-file limit. Large Actions artifacts have one-day retention and are deleted after successful durable release attachment; deployment recovery uses GitHub Release assets. PR jobs upload small JSON records rather than image archives. Expect several GiB of temporary release-run storage across six native builds and assembly; assembly is divided by SDK variant to limit runner disk use. The draft-creation job alone has Actions write permission to delete these transient copies. 4. After review and explicit approval, publish the draft as the latest GitHub Release. `deploy.yml` resolves `releases/latest/download/csrun.ps1` **once**, verifies GitHub's asset digest/size and release ID, and requires that release to match the deployment request. It verifies tag ancestry on main, the successful authoritative tag release run, both native results and the saved image engine checksum. Consequently the image built before publication must contain byte-identical released engine content. No build occurs after publication or during deployment. -5. The separate `Production` environment job promotes the existing OCI index to `docker.io/codebeltnet/csrun`, preserving all platform and attestation manifests. SDK patch, major.minor and major aliases reference the same content. There is **no Docker `latest` tag**, JCR or GHCR destination. Promotion fails if Skopeo cannot preserve child digests. CD inspects each registry index, downloads the published content by immutable digest, and validates its platforms, blobs, SBOM and provenance again. Workflow summaries contain tags, final index digest, both native results, exact SDK inventories, sizes, GitHub Release, source commit and engine checksum. +5. One approval of the separate `Production` environment job covers all three SDK variants (`10`, `11`, `10-11`). The job promotes them sequentially, attempts every variant even if one fails, and fails overall if any promotion fails. It promotes each existing OCI index to `docker.io/codebeltnet/csrun`, preserving all platform and attestation manifests. SDK patch, major.minor and major aliases reference the same content. There is **no Docker `latest` tag**, JCR or GHCR destination. Promotion fails if Skopeo cannot preserve child digests. CD inspects each registry index, downloads the published content by immutable digest, and validates its platforms, blobs, SBOM and provenance again. Workflow summaries contain tags, final index digest, both native results, exact SDK inventories, sizes, GitHub Release, source commit and engine checksum. Configure the `Production` GitHub environment with required reviewers and restricted deployment refs **before enabling publication**. Store a Docker Hub account name in `DOCKERHUB_USERNAME` and a repository-scoped access token in `DOCKERHUB_TOKEN` as environment secrets. Only the publishing step receives these secrets; authentication uses stdin and a temporary auth file removed on exit. PRs, release preparation and artifact verification never receive Docker Hub credentials. Repository environment protection and branch required checks are administrator settings; adding workflow YAML does not configure them.