Skip to content

Commit 0e67eb3

Browse files
committed
fix: bind lifecycle attestations to exact release artifacts
1 parent a2b5017 commit 0e67eb3

5 files changed

Lines changed: 189 additions & 107 deletions

File tree

‎.github/workflows/package-smoke.yml‎

Lines changed: 97 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -93,57 +93,21 @@ jobs:
9393
with:
9494
name: lifecycle-acceptance
9595
path: fixture
96-
- uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
9796
- name: Sign the fixture's lifecycle predicate
9897
id: attest
9998
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4
10099
with:
101-
subject-path: fixture/lifecycle-sample.txt
100+
subject-checksums: fixture/lifecycle-subjects.sha256
102101
predicate-type: ${{ env.PREDICATE_TYPE }}
103102
predicate-path: fixture/predicate.json
104-
- name: Test both verifiers against the signed fixture
105-
working-directory: fixture
103+
- name: Stage the signature bundle
106104
env:
107-
GH_TOKEN: ${{ github.token }}
108105
BUNDLE: ${{ steps.attest.outputs.bundle-path }}
109-
ATTESTATION_URL: ${{ steps.attest.outputs.attestation-url }}
110-
run: |
111-
set -euo pipefail
112-
cp -- "$BUNDLE" lifecycle.sigstore.json
113-
signer="$GITHUB_REPOSITORY/.github/workflows/package-smoke.yml"
114-
verify_gh() {
115-
gh attestation verify "$1" --bundle lifecycle.sigstore.json --repo "$GITHUB_REPOSITORY" \
116-
--signer-workflow "$2" --source-ref "$GITHUB_REF" --source-digest "$GITHUB_SHA" \
117-
--predicate-type "$PREDICATE_TYPE" --deny-self-hosted-runners
118-
}
119-
verify_cosign() {
120-
cosign verify-blob-attestation "$1" --bundle lifecycle.sigstore.json --check-claims=true \
121-
--type "$PREDICATE_TYPE" --certificate-identity "https://github.com/$2@$GITHUB_REF" \
122-
--certificate-oidc-issuer https://token.actions.githubusercontent.com
123-
}
124-
expect_rejection() {
125-
if "$@"; then
126-
echo "Expected rejection: $*" >&2
127-
exit 1
128-
fi
129-
}
130-
verify_gh lifecycle-sample.txt "$signer"
131-
verify_cosign lifecycle-sample.txt "$signer"
132-
cp lifecycle-sample.txt modified.txt
133-
printf 'modified\n' >> modified.txt
134-
expect_rejection verify_gh modified.txt "$signer"
135-
expect_rejection verify_cosign modified.txt "$signer"
136-
wrong_signer="$GITHUB_REPOSITORY/.github/workflows/release-attest.yml"
137-
expect_rejection verify_gh lifecycle-sample.txt "$wrong_signer"
138-
expect_rejection verify_cosign lifecycle-sample.txt "$wrong_signer"
139-
printf 'Both verifiers accepted the fixture and rejected modified bytes and the wrong signer.\n\nAttestation: %s\n' \
140-
"$ATTESTATION_URL" >> "$GITHUB_STEP_SUMMARY"
106+
run: cp -- "$BUNDLE" lifecycle.sigstore.json
141107
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
142108
with:
143109
name: lifecycle-acceptance-signed
144-
path: |
145-
fixture/lifecycle-sample.txt
146-
fixture/lifecycle.sigstore.json
110+
path: lifecycle.sigstore.json
147111
if-no-files-found: error
148112

149113
gate-signed-lifecycle:
@@ -154,30 +118,98 @@ jobs:
154118
timeout-minutes: 5
155119
permissions:
156120
contents: read
121+
env:
122+
PREDICATE_TYPE: https://velella.sh/offing/attestation/v1/
157123
steps:
158124
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
159125
with:
160126
node-version: '24'
161127
package-manager-cache: false
162128
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
163129
with:
164-
name: lifecycle-gate-candidate
165-
path: candidate
130+
name: lifecycle-acceptance
131+
path: fixture
166132
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
167133
with:
168134
name: lifecycle-acceptance-signed
169135
path: fixture
170136
- name: Install the exact packed candidate
171-
working-directory: candidate/npm-install
137+
working-directory: fixture/npm-install
172138
run: npm ci --omit=dev --ignore-scripts --no-fund --no-audit
173139
- name: Fetch trust roots for offline verification
174140
working-directory: fixture
175141
run: gh attestation trusted-root > trusted_root.jsonl
142+
- uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
143+
- name: acc-lifecycle-attestation (clean consumer)
144+
working-directory: fixture
145+
env:
146+
GH_TOKEN: ${{ github.token }}
147+
run: |
148+
set -euo pipefail
149+
signer="$GITHUB_REPOSITORY/.github/workflows/package-smoke.yml"
150+
verify_gh() {
151+
gh attestation verify "$1" --bundle lifecycle.sigstore.json --repo "$GITHUB_REPOSITORY" \
152+
--signer-workflow "$2" --source-ref "$GITHUB_REF" --source-digest "$GITHUB_SHA" \
153+
--predicate-type "$PREDICATE_TYPE" --deny-self-hosted-runners
154+
}
155+
verify_cosign() {
156+
cosign verify-blob-attestation "$1" --bundle lifecycle.sigstore.json --check-claims=true \
157+
--type "$PREDICATE_TYPE" --certificate-identity "https://github.com/$2@$GITHUB_REF" \
158+
--certificate-oidc-issuer https://token.actions.githubusercontent.com
159+
}
160+
expect_rejection() {
161+
if "$@"; then
162+
echo "Expected rejection: $*" >&2
163+
exit 1
164+
fi
165+
}
166+
sha256sum offing-* velella-offing-*.tgz | cmp - lifecycle-subjects.sha256
167+
jq -er '.dsseEnvelope.payload' lifecycle.sigstore.json | base64 -d > lifecycle.intoto.json
168+
jq -e --slurpfile expected prepared.intoto.json '
169+
def ordered: .subject |= sort_by(.name);
170+
ordered == ($expected[0] | ordered)
171+
' lifecycle.intoto.json > /dev/null
172+
tarballs=(velella-offing-*.tgz)
173+
tar -xzf "${tarballs[0]}" \
174+
package/docs/spec/lifecycle-attestation/conformance/check.mjs \
175+
package/docs/spec/lifecycle-attestation/example/verify.mjs
176+
verifier=package/docs/spec/lifecycle-attestation/example/verify.mjs
177+
node package/docs/spec/lifecycle-attestation/conformance/check.mjs lifecycle.intoto.json
178+
for subject in offing-* velella-offing-*.tgz; do
179+
verify_gh "$subject" "$signer"
180+
verify_cosign "$subject" "$signer"
181+
node "$verifier" lifecycle.intoto.json "$subject" > /dev/null
182+
done
183+
wrong_signer="$GITHUB_REPOSITORY/.github/workflows/release-attest.yml"
184+
expect_rejection verify_gh "${tarballs[0]}" "$wrong_signer"
185+
expect_rejection verify_cosign "${tarballs[0]}" "$wrong_signer"
186+
mkdir tampered
187+
tampered="tampered/${tarballs[0]}"
188+
cp -- "${tarballs[0]}" "$tampered"
189+
printf 'tampered' >> "$tampered"
190+
expect_rejection verify_gh "$tampered" "$signer"
191+
expect_rejection verify_cosign "$tampered" "$signer"
192+
expect_rejection node "$verifier" lifecycle.intoto.json "$tampered"
193+
for example in 2026-03-31:1 2026-04-01:0 2026-04-02:-1; do
194+
npm-install/node_modules/.bin/offing attest check lifecycle.sigstore.json \
195+
--subject "${tarballs[0]}" --today "${example%:*}" |
196+
rg --fixed-strings -- '"pkg:docker/library/alpine@3.18"' |
197+
rg --fixed-strings -- ": ${example#*:} days left"
198+
done
199+
{
200+
printf '### acc-lifecycle-attestation (clean consumer)\n\n'
201+
printf 'Signed subjects at %s\n\n' "$GITHUB_SHA"
202+
printf '```text\n'
203+
cat lifecycle-subjects.sha256
204+
printf '```\n\nBoth signature verifiers rejected the wrong signer and modified bytes. The installed CLI reproduced the documented day counts.\n'
205+
} >> "$GITHUB_STEP_SUMMARY"
176206
- name: Evaluate the signed predicate on either side of the deadline
177207
working-directory: fixture
178208
run: |
179209
set -euo pipefail
180-
bin=../candidate/npm-install/node_modules/.bin/offing
210+
bin=npm-install/node_modules/.bin/offing
211+
tarballs=(velella-offing-*.tgz)
212+
tarball="${tarballs[0]}"
181213
signer="$GITHUB_REPOSITORY/.github/workflows/package-smoke.yml"
182214
export GH_CONFIG_DIR="$RUNNER_TEMP/offing-gate-gh"
183215
export OFFING_DATA_VERSION=bundled
@@ -187,10 +219,10 @@ jobs:
187219
--today "$2" --within-days 0 --no-data ignore --json
188220
}
189221
190-
gate lifecycle-sample.txt 2026-03-31 |
222+
gate "$tarball" 2026-03-31 |
191223
jq -e '.asOf == "2026-03-31" and .decisions[0].input.kind == "attestation" and .decisions[0].verdict == "pass"'
192224
status=0
193-
gate lifecycle-sample.txt 2026-04-01 > gate.json || status=$?
225+
gate "$tarball" 2026-04-01 > gate.json || status=$?
194226
test "$status" -eq 1
195227
jq -e '
196228
.asOf == "2026-04-01" and .decisions[0].verdict == "block" and
@@ -199,10 +231,8 @@ jobs:
199231
.deadline == "2026-04-01" and .daysLeft == 0 and .outcome == "block")
200232
' gate.json
201233
202-
cp lifecycle-sample.txt modified.txt
203-
printf 'modified\n' >> modified.txt
204234
status=0
205-
gate modified.txt 2026-04-01 > rejected.json 2> rejected.err || status=$?
235+
gate "tampered/$tarball" 2026-04-01 > rejected.json 2> rejected.err || status=$?
206236
test "$status" -eq 4
207237
jq -e '
208238
.schemaVersion == "offing.error.v1" and .error.reason == "invalid-input" and .error.exitCode == 4 and
@@ -211,7 +241,7 @@ jobs:
211241
212242
{
213243
printf '### acc-release-gate (signed lifecycle fixture)\n\n'
214-
printf -- '- Candidate tarball SHA-256 %s\n' "$(sha256sum ../candidate/*.tgz | cut -d ' ' -f 1)"
244+
printf -- '- Candidate tarball SHA-256 %s\n' "$(sha256sum "$tarball" | cut -d ' ' -f 1)"
215245
printf -- '- Installed CLI %s at %s\n' "$("$bin" --version)" "$GITHUB_SHA"
216246
printf -- '- The verified predicate passed before the deadline, blocked on it, and refused modified bytes.\n'
217247
} >> "$GITHUB_STEP_SUMMARY"
@@ -817,39 +847,36 @@ jobs:
817847
printf -- '- Unsigned statement, packaged schema and template, and standalone conformance verified.\n'
818848
} >> "$GITHUB_STEP_SUMMARY"
819849
820-
- name: Prepare a synthetic subject for live lifecycle signing
850+
- name: Stage the exact packed candidate and five synthetic binary subjects
821851
if: github.event_name == 'workflow_dispatch'
822852
working-directory: ${{ runner.temp }}
823853
run: |
824854
set -euo pipefail
825-
mkdir lifecycle-acceptance
855+
mkdir -p lifecycle-acceptance/npm-install
856+
cp package-smoke/*.tgz lifecycle-acceptance/
857+
cp package-smoke/npm-install/{package.json,package-lock.json} lifecycle-acceptance/npm-install/
826858
cd lifecycle-acceptance
827-
printf 'Offing lifecycle attestation test fixture\n' > lifecycle-sample.txt
859+
version="$("$RUNNER_TEMP/package-smoke/npm-install/node_modules/.bin/offing" --version)"
860+
for target in linux-x64 linux-arm64 darwin-x64 darwin-arm64 win32-x64.exe; do
861+
printf 'Offing lifecycle attestation synthetic %s binary\n' "$target" > "offing-$version-$target"
862+
done
863+
sha256sum offing-* velella-offing-*.tgz > lifecycle-subjects.sha256
828864
"$RUNNER_TEMP/package-smoke/npm-install/node_modules/.bin/offing" attest \
829-
--subject lifecycle-sample.txt --sbom "$GITHUB_WORKSPACE/tests/fixtures/attestation/bom.cdx.json" \
830-
--data-version bundled | jq -e '.predicate' > predicate.json
865+
--subject velella-offing-*.tgz --sbom "$GITHUB_WORKSPACE/tests/fixtures/attestation/bom.cdx.json" \
866+
--data-version bundled > draft.json
867+
jq -e '.predicate' draft.json > predicate.json
868+
jq -R -s --slurpfile draft draft.json '
869+
[split("\n")[] | select(length > 0) | split(" ") | {name: .[1], digest: {sha256: .[0]}}] as $subjects
870+
| $draft[0] | .subject = $subjects
871+
' lifecycle-subjects.sha256 > prepared.intoto.json
872+
rm draft.json
831873
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
832874
if: github.event_name == 'workflow_dispatch'
833875
with:
834876
name: lifecycle-acceptance
835877
path: ${{ runner.temp }}/lifecycle-acceptance/
836878
if-no-files-found: error
837879

838-
- name: Stage the exact packed candidate for signed gate acceptance
839-
if: github.event_name == 'workflow_dispatch'
840-
working-directory: ${{ runner.temp }}
841-
run: |
842-
set -euo pipefail
843-
mkdir -p lifecycle-gate-candidate/npm-install
844-
cp package-smoke/*.tgz lifecycle-gate-candidate/
845-
cp package-smoke/npm-install/{package.json,package-lock.json} lifecycle-gate-candidate/npm-install/
846-
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
847-
if: github.event_name == 'workflow_dispatch'
848-
with:
849-
name: lifecycle-gate-candidate
850-
path: ${{ runner.temp }}/lifecycle-gate-candidate/
851-
if-no-files-found: error
852-
853880
- name: acc-release-gate (installed CLI and standalone fixtures)
854881
working-directory: ${{ runner.temp }}
855882
env:

‎.github/workflows/release-attest.yml‎

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,29 @@ jobs:
3535
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
3636
with:
3737
name: lifecycle-release-sbom
38-
- name: Prepare a release tarball alongside the five binary assets
38+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
39+
with:
40+
name: first-minute-candidate
41+
path: subjects
42+
- name: Check the candidate tarball and required binary assets
3943
env:
4044
DRY_RUN: ${{ inputs.dry_run }}
4145
run: |
4246
set -euo pipefail
4347
version="$(node -p 'require("./package.json").version')"
4448
npm run build --silent
45-
if [ "$DRY_RUN" = true ]; then
46-
test -f "subjects/offing-$version-linux-x64"
47-
npm pack --ignore-scripts --pack-destination subjects
48-
else
49+
targets=(linux-x64)
50+
if [ "$DRY_RUN" = false ]; then
4951
test "$GITHUB_REF" = "refs/tags/v$version"
50-
for target in linux-x64 linux-arm64 darwin-x64 darwin-arm64 win32-x64.exe; do
51-
test -f "subjects/offing-$version-$target"
52-
done
53-
npm pack --ignore-scripts --registry https://registry.npmjs.org --pack-destination subjects "@velella/offing@$version"
52+
targets+=(linux-arm64 darwin-x64 darwin-arm64 win32-x64.exe)
5453
fi
55-
test -f "subjects/velella-offing-$version.tgz"
54+
subjects=("subjects/velella-offing-$version.tgz")
55+
for target in "${targets[@]}"; do
56+
subjects+=("subjects/offing-$version-$target")
57+
done
58+
for subject in "${subjects[@]}"; do test -f "$subject"; done
59+
actual=(subjects/offing-* subjects/velella-offing-*.tgz)
60+
test "${#actual[@]}" -eq "${#subjects[@]}"
5661
- name: Generate the shared lifecycle predicate and subject digests
5762
run: |
5863
set -euo pipefail
@@ -77,13 +82,6 @@ jobs:
7782
name: lifecycle-release
7883
path: lifecycle-release/
7984
if-no-files-found: error
80-
- name: Upload the candidate tarball for independent verification
81-
if: inputs.dry_run
82-
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
83-
with:
84-
name: lifecycle-release-tarball
85-
path: subjects/velella-offing-*.tgz
86-
if-no-files-found: error
8785

8886
sign:
8987
if: ${{ !inputs.dry_run && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
@@ -112,6 +110,12 @@ jobs:
112110
run: |
113111
set -euo pipefail
114112
cp -- "$BUNDLE" lifecycle.sigstore.json
115-
jq -er '.dsseEnvelope.payload' lifecycle.sigstore.json | base64 -d > lifecycle.intoto.json
113+
jq -er '.dsseEnvelope.payload' lifecycle.sigstore.json | base64 -d > signed.json
114+
jq -e --slurpfile expected lifecycle.intoto.json '
115+
def ordered: .subject |= sort_by(.name);
116+
ordered == ($expected[0] | ordered)
117+
' signed.json > /dev/null
118+
mv signed.json lifecycle.intoto.json
116119
sha256sum lifecycle.intoto.json lifecycle.sigstore.json lifecycle-subjects.sha256 > lifecycle-evidence.sha256
117-
gh release upload --repo "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" lifecycle.intoto.json lifecycle.sigstore.json lifecycle-subjects.sha256 lifecycle-evidence.sha256 --clobber
120+
gh release upload --repo "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" \
121+
lifecycle.intoto.json lifecycle.sigstore.json lifecycle-subjects.sha256 lifecycle-evidence.sha256 --clobber

0 commit comments

Comments
 (0)