Repository navigation
ci: gate the pacquet release publish job behind the release environment - #12641
Conversation
pacquet-release-to-npm.yml can be triggered via workflow_dispatch. Its publish job uses npm OIDC trusted publishing to publish the pacquet, `@pnpm/pacquet`, and pnpm-pacquet packages. It had no environment gate, so any collaborator with write access could publish to npm via a manual dispatch without reviewer approval. Add an environment: release gate to the publish job (the build job produces no externally visible artifacts and is intentionally left ungated), matching the protection used by release.yml. Co-authored-by: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe npm release workflow now runs its ChangesRelease workflow environment binding
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoGate pacquet npm publish job behind the protected release environment Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Ref bypasses release gate
|
| publish: | ||
| name: Publish | ||
| runs-on: ubuntu-latest | ||
| environment: release |
There was a problem hiding this comment.
1. Ref bypasses release gate 🐞 Bug ⛨ Security
pacquet-release-to-npm.yml is workflow_dispatch and has no ref validation step (unlike release.yml), so a write-access collaborator can dispatch and run a modified copy of this workflow from another ref where the environment: release gate is removed. This undermines the intended reviewer-approval control for npm publishing via OIDC.
Agent Prompt
## Issue description
`pacquet-release-to-npm.yml` is manually dispatchable and currently relies on `environment: release` for approval gating, but it does not validate that the workflow is running from a trusted release ref. Because `workflow_dispatch` can be run against non-default refs, a collaborator with write access can run a modified workflow definition from another ref (e.g., with the `environment` gate removed) and bypass the intended approval gate.
## Issue Context
`release.yml` explicitly defends against this class of issue by validating the ref early and failing if it is not a version tag. `pacquet-release-to-npm.yml` should add a similar early validation (but for the default branch), and make the build/publish sequence depend on it.
## Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[7-22]
- .github/workflows/pacquet-release-to-npm.yml[22-65]
- .github/workflows/pacquet-release-to-npm.yml[140-149]
## Proposed fix
1. Add a new job (e.g. `validate-release-ref`) at the start of the workflow with `permissions: {}`.
2. In that job, check `${GITHUB_REF}` equals the repository default branch ref (e.g. `refs/heads/${{ github.event.repository.default_branch }}`) and fail otherwise.
3. Make `build` depend on this validation job (so the expensive matrix doesn’t run on untrusted refs), and keep `publish` depending on `build` (transitively enforcing the validation).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit eb089c5 |
|
Thanks @qodo — re: Ref bypasses release gate (no ref validation): same disposition as the equivalent finding on the pnpr release workflow (#12640). The Written by an agent (Claude Code, claude-opus-4-8). |
Agreed — for this PR,
|
|
again, why 3 PRs for the same thing? |
Summary
pacquet-release-to-npm.ymlcan be triggered viaworkflow_dispatch. Itspublishjob uses npmOIDC trusted publishing to publish the
pacquet,@pnpm/pacquet, andpnpm-pacquetpackages(plus the per-target sub-packages). The job had no
environment: releasegate, so anycollaborator with write access could publish these packages to npm via a manual dispatch without
reviewer approval — unlike
release.yml, which gates its publishing job.This adds
environment: releaseto thepublishjob. Thebuildjob produces no externallyvisible artifacts and is intentionally left ungated so the matrix legs are not blocked on approval.
Squash Commit Body
Checklist
(No changeset: no published package changes. CI-only change.)
Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit