Repository navigation
fix(ci): keep the release token out of .git/config while npm ci runs - #904
Conversation
…861) The publish job holds contents/packages/id-token/attestations write and runs `npm ci` against the tag. actions/checkout persists the workflow token in `.git/config` by default, so a dependency lifecycle script could read it. Set `persist-credentials: false`: the steps that need the API already pass `secrets.GITHUB_TOKEN` explicitly. Docs: docs/autonomous-dev.md Docs-not-needed: no
There was a problem hiding this comment.
Verdict: PASS at 28ac4cd
The job has exactly one checkout (.github/workflows/release.yml:53) and it now sets persist-credentials: false (:57), so .git/config holds no token while npm ci (:63) runs dependency scripts; every step that needs the API passes its own credential — GH_TOKEN (:85, :209), GHCR_TOKEN (:156), registry-password (:178) — and the only job-level env is RELEASE_TAG.
No step lost a credential it needs: git fetch origin main (:88) is an anonymous HTTPS fetch on this public repository, and docker login (:156-157) happens after the install, so nothing in the install path reads a credential store.
Non-blocking: test/releasePublishToken.test.ts:97-101 matches raw text, so a commented-out # persist-credentials: false still passes (measured below); strip # comments from the step lines before matching.
Non-blocking, now resolved: the pr-lint red on the earlier body was only its ## Ran: / ## Not run: headings; the body has been fixed and pr-lint is green (run 133147560035).
Findings: none blocking; the two points above are the only ones.
Ran:
npm run checkat this head in a clean tree: exit 0, 2405 tests / 2405 pass, lint + tsc + build clean.npx tsx --test test/releasePublishToken.test.tsat this head: 1 pass / 0 fail; with the baserelease.ymlswapped in: 1 fail / 0 pass.- Mutation at this head, delete
persist-credentials: false: 1 fail / 0 pass. - Mutation at this head, add a second checkout in the same job with no flag: 1 fail / 0 pass.
- Mutation at this head, comment the flag out: still 1 pass / 0 fail — the blind spot recorded above.
node scripts/changelog.mjs checkat this head: 23 fragment(s) ok.GITHUB_REPOSITORY=HugoXK/fledge node scripts/pr-lint.mjs --pr 904on the base tree: FAIL, the two body-heading errors only.
Not run:
- A real tag publish: it pushes an image and a release, and that is the owner's action.
- No live
release.ymlrun; the diff is awith:key plus a text-level test.
Written-by: HugoXK-bot
Author: Fledge Platform Verdict
Written-by: HugoXK
Author: Fledge Platform Dev-2
Fixes #861
What changed
The release publish job holds
contents: write,packages: write,id-token: writeandattestations: write, and it runsnpm ciagainst the tag.actions/checkoutwrites the workflow token into.git/configunless told not to, so a dependency lifecycle script running during that install could read a token with publish permissions..github/workflows/release.yml— the checkout that feedsnpm cinow setspersist-credentials: false. Nothing else in the job relied on the persisted copy: the provenance step already passessecrets.GITHUB_TOKENexplicitly asGH_TOKEN, so the only user of the credential store was the implicit one.test/releasePublishToken.test.ts— the red test. It readsrelease.ymlas text (the same waytest/ciConcurrency.test.tsreadsci.yml) and requires every job that holdscontents: writeand runsnpm cito havepersist-credentials: falseon its checkout. A job this helper cannot see fails instead of passing quietly.docs/autonomous-dev.md— one paragraph on the release job's token handling, next to the existingrelease.ymldescription.changelog.d/861-release-publish-token.security.md— the fragment.Not changed, deliberately: the workflow permissions stay as they are (the publish needs them), and no
npm ci --ignore-scriptswas added — the vendor's lockfile scripts are part of a normal install, and the fix belongs where the credential is, not where the script runs.Ran:
npx tsx --test test/releasePublishToken.test.tsat base3672754cand at the tip28ac4cd899c13525141a7312eff113cb1a94acb2: 1 fail / 0 pass before the change (the checkout had nopersist-credentials), 1 pass / 0 fail after.npm run checkon the tip's tree: exit 0 — lint clean,tsc --noEmitclean, 2405 tests / 2405 pass / 0 fail, build clean.node scripts/changelog.mjs check—23 fragment(s) ok.Not run:
with:key read by the workflow file, and the new test is the check that runs in CI.npm run dev— no user-visible surface changes.Risk and rollback
T3 by path (
.github/**);risk-gatehas the last word. The blast radius is the release job only, and the change removes a credential rather than adding reach. Rollback is one line: deletepersist-credentials: false. If a later step turns out to need the persisted credential, the failure is an explicit auth error at tag time, not a silent one.Docs
docs/autonomous-dev.mdupdated in this PR — the release job's token handling is stated beside the job description. Fragments: one,changelog.d/861-release-publish-token.security.md.