Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions .github/workflows/supply-chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,22 @@ jobs:
# the loop by running it ourselves against the real published tarballs
# rather than the local workspace. npm (not pnpm) on purpose: the
# signature audit needs an npm-resolved tree and lockfile.
# bestax-migrate is deliberately absent: its published manifest still
# carries an unresolved `workspace:^` specifier, so `npm install` of it
# fails outright and would mask real signature failures here. Add it back
# once that is fixed.
#
# This step is itself the assertion, not just setup for the audit below:
# `npm install` exits non-zero on an uninstallable package, so the job
# goes red whether the artifact is unsigned or simply broken. That is the
# check #412 did not have — it shipped an uninstallable `workspace:^`
# manifest precisely because everything else in CI resolves against the
# workspace, where the specifier works.
#
# Keep this list in sync with the provenance loop below.
- name: Install published packages into a scratch tree
run: |
mkdir -p "$RUNNER_TEMP/verify"
cd "$RUNNER_TEMP/verify"
npm init -y > /dev/null
npm install --ignore-scripts \
@allxsmith/bestax-bulma create-bestax
@allxsmith/bestax-bulma create-bestax bestax-migrate
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

- name: Audit registry signatures and provenance attestations
run: |
Expand All @@ -312,7 +317,27 @@ jobs:
- name: Assert our packages actually carry provenance
run: |
fail=0
for pkg in @allxsmith/bestax-bulma create-bestax; do
cd "$RUNNER_TEMP/verify"
for pkg in @allxsmith/bestax-bulma create-bestax bestax-migrate; do
# Pin to the version that was actually installed and audited above.
# A bare `npm view "$pkg"` re-resolves the `latest` dist-tag, which
# is mutable, so a publish landing between the install step and this
# one would have this step vouch for a version the job never
# installed. Reading the version back out of the tree keeps all
# three steps talking about the same artifacts. Local read, no
# network, so it belongs outside the retry loop below.
#
# Absent from the tree is its own failure, reported as such rather
# than folded into the "no provenance" message below — a missing
# install and a dropped attestation want different investigations.
version=$(npm ls "$pkg" --depth=0 --json 2>/dev/null \
| jq -r --arg pkg "$pkg" '.dependencies[$pkg].version // empty' 2>/dev/null || true)
if [ -z "$version" ]; then
echo "::error::$pkg is not in the installed tree; cannot verify its provenance"
fail=1
continue
fi

# --json + a type guard so only a real string counts as present:
# null, undefined, [] and non-strings all collapse to empty. The
# array branch covers npm aggregating a bare spec into one element.
Expand All @@ -325,16 +350,16 @@ jobs:
# spend three attempts before believing provenance is really gone.
predicate=""
for attempt in 1 2 3; do
predicate=$(npm view "$pkg" dist.attestations.provenance.predicateType --json 2>/dev/null \
predicate=$(npm view "$pkg@$version" dist.attestations.provenance.predicateType --json 2>/dev/null \
| jq -r 'if type=="array" then .[0] else . end | select(type=="string")' 2>/dev/null || true)
[ -n "$predicate" ] && break
[ "$attempt" -lt 3 ] && sleep $((attempt * 5))
done
if [ -z "$predicate" ]; then
echo "::error::$pkg has NO provenance attestation on the registry"
echo "::error::$pkg@$version has NO provenance attestation on the registry"
fail=1
else
echo "ok: $pkg -> $predicate"
echo "ok: $pkg@$version -> $predicate"
fi
done
exit "$fail"
Loading