chore: harden release workflow for supply-chain security#168
chore: harden release workflow for supply-chain security#168thetutlage 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)
📝 WalkthroughWalkthroughAdds Dependabot for GitHub Actions, sets explicit workflow permissions and concurrency, pins action references and checkout/setup-node to commit SHAs, updates the release job to use GITHUB_TOKEN with npm audit signatures and ignore-scripts install, and enables tracking of package-lock.json. ChangesWorkflow Security and Dependency Management
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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/release.yml (1)
25-27: ⚡ Quick winConsider setting
persist-credentials: falseif git push is handled via explicit token.The static analyzer flags that persisted credentials increase attack surface. However, if the release script pushes tags or version commits, it may rely on these credentials.
If
npm run releasehandles git authentication via theGITHUB_TOKENenv var explicitly, add:- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: fetch-depth: 0 + persist-credentials: falseIf the release tool relies on the checkout action's persisted credentials for git push, keep the current configuration.
🤖 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/release.yml around lines 25 - 27, The checkout step currently uses actions/checkout with fetch-depth: 0 and leaves credentials persisted; change the checkout step configuration (the actions/checkout invocation) to set persist-credentials: false if your release script (npm run release) authenticates pushes explicitly via GITHUB_TOKEN, so the action does not leak the default token; if instead your release process relies on the checkout-provided credentials to push tags/commits, leave persist-credentials as-is and document that behavior in the workflow and release script to avoid the static analyzer warning.
🤖 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/release.yml:
- Around line 25-27: The checkout step currently uses actions/checkout with
fetch-depth: 0 and leaves credentials persisted; change the checkout step
configuration (the actions/checkout invocation) to set persist-credentials:
false if your release script (npm run release) authenticates pushes explicitly
via GITHUB_TOKEN, so the action does not leak the default token; if instead your
release process relies on the checkout-provided credentials to push
tags/commits, leave persist-credentials as-is and document that behavior in the
workflow and release script to avoid the static analyzer warning.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5adb2c7c-3cec-4733-b5bb-02556a950a53
⛔ 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