Skip to content

fix(ci): do not persist write-scoped checkout tokens in publish and merge-gate - #282

Merged
adityankale190895 merged 2 commits into
DiffCI:mainfrom
FredApps:fix/checkout-persisted-write-token
Nov 18, 2026
Merged

adityankale190895 merged 2 commits into
DiffCI:mainfrom
FredApps:fix/checkout-persisted-write-token

Conversation

@FredApps

Copy link
Copy Markdown
Contributor

Fixes #281

  • release-cli.yml publish and ci.yml merge-gate check out with persist-credentials: false, so their write-scoped GITHUB_TOKEN is no longer stored in .git/config while npm ci runs install scripts. Neither job uses git with that token. publish works through gh and the API with GH_TOKEN, and merge-gate posts its check run with the Action's github-token input.
  • New tests/workflow-credentials.test.ts (added to release-files.json) reads every workflow and fails when a job whose token has a write scope (other than id-token) checks out with persisted credentials and does not git push. Before this change it reported ci.yml merge-gate and release-cli.yml publish. credit-contributors.yml is exempt because it pushes.

This PR's own Merge gate smoke run covers the merge-gate change, including the shallow checkout's unshallow fetch without stored credentials.

Validation: npx tsx --test tests/workflow-credentials.test.ts tests/cli-workflow-templates.test.ts, npm run typecheck, npm run audit:boundary.

…ffCI#280

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 01:07
@adityankale190895
adityankale190895 merged commit 6088664 into DiffCI:main Nov 18, 2026
13 checks passed
adityankale190895 added a commit that referenced this pull request Nov 19, 2026
…a job that runs no scripts

While a job has id-token: write, every step can request the OIDC token npm
trusted publishing accepts. The publish job also ran npm ci with install
scripts, an unpinned npm@11 install, the build and npm publish's prepack,
so a compromised dependency could publish @diffci.com/diffci with valid
provenance. #282 kept the contents: write token off disk but cannot cover
this one.

Split it, as proposed in #301:
- build (contents: read): tag check, npm ci, packaging checks, typecheck,
  build, package:check/smoke, then npm pack with gitHead set to the
  release commit, uploading the tarball and recording its sha512.
- publish (id-token: write only): no checkout, no npm cache, npm pinned to
  11.21.2 and installed with --ignore-scripts. Checks the tarball's sha512,
  name, version against the tag and gitHead against the commit, then
  publishes it with --provenance --ignore-scripts and waits for npm.
- release (contents: write, no id-token): observer smoke, GitHub Release,
  provenance assets, action-v tag, verify-release, unchanged.

npm only fills gitHead itself when publishing from a git checkout; a
gitHead already in the tarball's package.json is kept (checked against
npm 11's pacote and libnpmpublish), so the re-run check still works.

New tests fail on the old workflow: jobs that can mint an OIDC token run
no install or publish without --ignore-scripts, and the release publishes
the built tarball from a job without a write token.

Fixes #301.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflows: publish and merge-gate leave a write-scoped token in .git/config while npm install scripts run

2 participants