From f428f095fcb7dc0306c4fbe07930c1fef847d42d Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Mon, 16 Nov 2026 02:24:23 +0100 Subject: [PATCH] fix(publish-app): refuse release tags with build metadata The own-release signer identity carries the full tag, and the platform's own-release grammar has no build suffix, so a v1.2.3+build.5 release would publish with a signature the platform rejects. Two such tags would also collide on the same OCI version. Refuse them at admission instead. Refs devantler-tech/platform#6378 Co-Authored-By: Claude Opus 5.5 --- .github/tests/test-publish-app-action.sh | 17 ++++++++++------- actions/publish-app/README.md | 4 ++-- actions/publish-app/action.yaml | 2 +- actions/publish-app/admit.sh | 16 ++++++++-------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/tests/test-publish-app-action.sh b/.github/tests/test-publish-app-action.sh index 5ce25549..972e9139 100644 --- a/.github/tests/test-publish-app-action.sh +++ b/.github/tests/test-publish-app-action.sh @@ -562,21 +562,24 @@ for ref in refs/heads/main refs/pull/7/merge refs/heads/v1.2.3 v1.2.3; do case_ref "$action_dir" "$ref" 'must run on a release tag' || fail "accepted or misjudged non-tag ref $ref: $(cat "$log")" done long_pre="$(printf 'a%.0s' $(seq 1 130))" -long_build="$(printf 'b%.0s' $(seq 1 251))" -for tag in v1.2.3garbage v1.2.3.4 v1.2 v1 1.2.3 V1.2.3 v01.2.3 v1.02.3 v1.2.03 v1.2.3- v1.2.3+ v1.2.3-01 \ - v1.2.3-rc..1 v1.2.3-rc.1+ v1.2.3+build..1 v1.2.3_build 'v1.2.3 ' ' v1.2.3' v1.2.3-ünicode; do +long_tag_pre="$(printf 'c%.0s' $(seq 1 251))" +for tag in v1.2.3garbage v1.2.3.4 v1.2 v1 1.2.3 V1.2.3 v01.2.3 v1.02.3 v1.2.03 v1.2.3- v1.2.3-01 \ + v1.2.3-rc..1 v1.2.3_build 'v1.2.3 ' ' v1.2.3' v1.2.3-ünicode; do case_ref "$action_dir" "refs/tags/$tag" 'complete semantic version' || fail "accepted or misjudged tag '$tag': $(cat "$log")" done -for tag in v9007199254740992.0.0 v1.0.18446744073709551616 v1.2.3-rc.1000000000000000 "v1.2.3+$long_build"; do +for tag in v1.2.3+build.5 v1.2.3-rc.1+build.5 v1.2.3+ v1.2.3-rc.1+ v1.2.3+build..1; do + case_ref "$action_dir" "refs/tags/$tag" 'carries build metadata' || fail "accepted build metadata in tag '$tag': $(cat "$log")" +done +for tag in v9007199254740992.0.0 v1.0.18446744073709551616 v1.2.3-rc.1000000000000000 "v1.2.3-$long_tag_pre"; do case_ref "$action_dir" "refs/tags/$tag" 'at most 256 characters with numbers of at most 15 digits' || fail "accepted an unreadable version $tag: $(cat "$log")" done case_ref "$action_dir" "refs/tags/v1.2.3-$long_pre" 'longer than the 128 characters' || fail 'accepted an over-long OCI version' -echo 'ok only a complete v tag ref is admitted, before any registry contact' +echo 'ok only a complete v tag ref without build metadata is admitted, before any registry contact' for entry in "v0.0.0|0.0.0|latest" "v10.20.30|10.20.30|latest" "v1.2.3-rc.1|1.2.3-rc.1|" \ - "v1.0.0-alpha.beta.1|1.0.0-alpha.beta.1|" "v1.0.0-x-y-z.--|1.0.0-x-y-z.--|" "v1.2.3+build.5|1.2.3|latest" \ - "v1.2.3-rc.1+build.5|1.2.3-rc.1|" "v999999999999999.0.0|999999999999999.0.0|latest"; do + "v1.0.0-alpha.beta.1|1.0.0-alpha.beta.1|" "v1.0.0-x-y-z.--|1.0.0-x-y-z.--|" \ + "v999999999999999.0.0|999999999999999.0.0|latest"; do IFS='|' read -r tag version latest <<<"$entry" setup_case "$released" sim_ref="refs/tags/$tag" diff --git a/actions/publish-app/README.md b/actions/publish-app/README.md index 657c3681..55a2b828 100644 --- a/actions/publish-app/README.md +++ b/actions/publish-app/README.md @@ -15,7 +15,7 @@ every revision of a shared publisher. 1. **Admits the release, before any registry contact.** It refuses unless: - the run's ref is `refs/tags/v` (SemVer 2.0.0; a pre-release is allowed, build - metadata is dropped from the published version, and every number has at most 15 digits); + metadata such as `+build.5` is refused, and every number has at most 15 digits); - the calling workflow ref is this repository's own workflow file on that exact tag; - the tagged commit is checked out at the workspace root, without a persisted git credential (`persist-credentials: false`; the checkout is also the image build context); @@ -72,7 +72,7 @@ directory on the way, nor the manifest itself, may be a link. A refused value is | Name | Description | |------|-------------| -| `version` | The published version: the tag without its `v` and build metadata | +| `version` | The published version: the tag without its `v` | | `image-digest` | The signed image digest (empty in `manifests` mode) | | `manifests-digest` | The signed manifests artifact digest | diff --git a/actions/publish-app/action.yaml b/actions/publish-app/action.yaml index df09355e..2bf9a8df 100644 --- a/actions/publish-app/action.yaml +++ b/actions/publish-app/action.yaml @@ -46,7 +46,7 @@ inputs: outputs: version: - description: "The published version: the tag without its `v` and build metadata." + description: "The published version: the tag without its `v`." value: ${{ steps.admit.outputs.version }} image-digest: description: "The signed image digest (empty in manifests mode)." diff --git a/actions/publish-app/admit.sh b/actions/publish-app/admit.sh index 5a3fc8d0..cea461a8 100644 --- a/actions/publish-app/admit.sh +++ b/actions/publish-app/admit.sh @@ -49,20 +49,20 @@ check_inputs() { fi } -# The ref must be refs/tags/v. Keep this identical to the tag step of the reusable -# publish workflows: Flux and docker/metadata-action must both be able to read and order it. +# The ref must be refs/tags/v without build metadata: Flux and docker/metadata-action +# must both be able to read and order it. The tag is part of the signing identity, and the +# platform verifies that identity with a grammar that has no build suffix. An OCI tag cannot +# carry `+` either, so v1.2.3+a and v1.2.3+b would both publish as 1.2.3. check_release_tag() { - local ref="${GITHUB_REF:-}" num pre build semver numbers too_long + local ref="${GITHUB_REF:-}" num pre semver numbers too_long [[ "$ref" == refs/tags/* ]] || fail 'publish-app must run on a release tag (refs/tags/v), not a branch or pull request ref' tag="${ref#refs/tags/}" num='(0|[1-9][0-9]*)' pre='(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)' - build='[0-9A-Za-z-]+' - semver="^v${num}\.${num}\.${num}(-${pre}(\.${pre})*)?(\+${build}(\.${build})*)?$" - [[ "$tag" =~ $semver ]] || fail 'the release tag must be a complete semantic version vMAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]' - # An OCI tag cannot carry `+`, and SemVer ignores build metadata when ordering versions. + case "$tag" in *+*) fail "the release tag $tag carries build metadata; tag the release as vMAJOR.MINOR.PATCH[-PRERELEASE] without a +BUILD suffix" ;; esac + semver="^v${num}\.${num}\.${num}(-${pre}(\.${pre})*)?$" + [[ "$tag" =~ $semver ]] || fail 'the release tag must be a complete semantic version vMAJOR.MINOR.PATCH[-PRERELEASE]' version="${tag#v}" - version="${version%%+*}" numbers=".${version%%-*}." case "$version" in *-*) numbers="${numbers}${version#*-}." ;; esac too_long='\.[0-9]{16,}\.'