chore: harden release workflow for supply-chain security#262
chore: harden release workflow for supply-chain security#262thetutlage wants to merge 5 commits into
Conversation
- Use npm Trusted Publishing (OIDC) instead of NPM_TOKEN - Pin third-party actions and reusable workflows to commit SHAs - Drop default permissions to read-only, elevate per-job - Add --ignore-scripts to release-time install - Add npm audit signatures step - Add Dependabot for github-actions ecosystem - Add concurrency guard Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Addresses CodeQL "Workflow does not contain permissions" finding by declaring contents: read at workflow scope so GITHUB_TOKEN is scoped down on push/pull_request/workflow_call runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Requires approval from the Core Team before npm publish runs, via the GitHub Environment created in each repo. Pair with an npm Trusted Publisher config that pins the environment to fully close the gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The hardened release workflow uses npm install --ignore-scripts and npm audit signatures, both of which require a lockfile to be effective: - npm audit signatures verifies registry signatures of the exact resolved versions in the lockfile; without one, transitive resolution at release time would re-resolve from the registry and silently accept any new version of a dep, which is the supply-chain hole we are trying to close. - --ignore-scripts is meaningful only when paired with reproducible resolution, otherwise an attacker who controls a future version of a transitive dep can still influence build output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughPins GitHub Actions and reusable workflows to specific commit SHAs, tightens workflow and job permissions, adds Dependabot for GitHub Actions (weekly), updates the release job (registry config, audit, --ignore-scripts), and removes ChangesCI/CD Security and Reproducibility Hardening
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/checks.yml (1)
33-34: ⚡ Quick winConsider adding
persist-credentials: falseto checkout steps.Since this workflow only runs tests and doesn't push to git, disabling credential persistence prevents the GITHUB_TOKEN from lingering in the workspace where it could potentially be accessed. This aligns with the PR's supply-chain hardening goals and addresses the zizmor static analysis findings.
🛡️ Example fix for one checkout step (apply to all four)
- - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + persist-credentials: falseAlso applies to: 63-64, 89-90, 108-109
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/checks.yml around lines 33 - 34, Add persist-credentials: false to every actions/checkout step to avoid leaving GITHUB_TOKEN in the workspace; specifically update each step that uses "uses: actions/checkout@..." (the four occurrences in the file) to include a step-level key persist-credentials: false directly under the step, keeping other keys (e.g., uses, with) unchanged so the checkout still functions but credentials are not persisted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/checks.yml:
- Around line 33-34: Add persist-credentials: false to every actions/checkout
step to avoid leaving GITHUB_TOKEN in the workspace; specifically update each
step that uses "uses: actions/checkout@..." (the four occurrences in the file)
to include a step-level key persist-credentials: false directly under the step,
keeping other keys (e.g., uses, with) unchanged so the checkout still functions
but credentials are not persisted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3e6361bf-4e1f-4871-ba6a-7450bfdcac8c
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/dependabot.yml.github/workflows/checks.yml.github/workflows/release.yml.gitignore
💤 Files with no reviewable changes (1)
- .gitignore
Re-adds 'secrets: inherit' to the checks job in release.yml so the reusable checks workflow continues to receive repository secrets when invoked by workflow_call from release. Without this, integration tests in checks that depend on secrets (e.g. RESEND_API_KEY in mail) fail during release runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
NPM_TOKENfrom the workflow, so transitivepostinstallscripts can no longer exfiltrate it from~/.npmrc.actions/checkout,actions/setup-node, and theadonisjs/.github/adonisjs/corereusable workflows to commit SHAs to defend against tag/branch reflog tampering.permissions:tocontents: read, elevates per-job (contents: write+id-token: writeonly on the release job).npm install --ignore-scriptsso transitive postinstall scripts cannot run during the release job.npm audit signaturesstep before publishing to verify registry signatures.github-actionsecosystem so the pinned SHAs are kept current automatically.concurrencyblock to prevent overlapping release runs.Prerequisites
release.yml, environment: none). Confirmed configured before this PR.NPM_TOKENcan be deleted after the first successful tokenless release.Test plan
releaseworkflow manually with a patch bump.NPM_TOKENbeing available.npm install --ignore-scriptsbreaks the build for this repo (e.g. a transitive dep relies onpostinstallto fetch a native binary), drop the flag in a follow-up.🤖 Generated with Claude Code
Summary by CodeRabbit