ci: add pnpm lockfile supply-chain audit gate#81
Conversation
lockfile-lint does not support pnpm lockfiles, so add a direct gate that fails CI if pnpm-lock.yaml contains insecure http:// resolutions or exotic git/tarball/directory sources. Package integrity (SHA-512) and lockfile drift are already enforced via pnpm install --frozen-lockfile.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
WalkthroughA new ChangesLockfile audit CI validation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 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)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
.github/workflows/test.yml (3)
18-19: ⚖️ Poor tradeoffConsider pinning checkout action and disabling credential persistence.
Static analysis flags two concerns:
- Action not pinned to a commit SHA (supply-chain risk)
persist-credentials: falsenot setHowever, these apply to all checkout steps in this file. For a security-focused audit job, pinning is more defensible, but changing just this job would be inconsistent with the rest of the workflow.
🤖 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/test.yml around lines 18 - 19, Update the Checkout step that currently uses actions/checkout@v4 to use a pinned commit SHA instead of a floating tag and add persist-credentials: false to the step; find the step with name "Checkout" and the uses value "actions/checkout@v4" and replace the tag with the specific commit SHA for actions/checkout and add the persist-credentials: false input to the step, and then apply the same pin+persist-credentials change consistently to all other checkout steps in the workflow to avoid inconsistency.
14-16: ⚡ Quick winConsider adding
needs: [lockfile-audit]to downstream jobs for a true supply-chain gate.Currently,
lint,test, andbuildrun in parallel withlockfile-audit. If the lockfile contains a malicious exotic/http source, those jobs may executepnpm installbefore the audit fails. Addingneeds: [lockfile-audit]to downstream jobs ensures no installs occur until the lockfile passes validation.If parallel execution is intentional (since the workflow ultimately fails either way), this is fine as-is.
🔗 Proposed fix to gate downstream jobs
lint: name: Lint runs-on: ubuntu-latest + needs: [lockfile-audit] steps:Apply similarly to
testandbuildjobs.🤖 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/test.yml around lines 14 - 16, Add an explicit dependency on the lockfile-audit job so downstream jobs don’t run installs before the audit completes: update the lint, test, and build job definitions to include needs: [lockfile-audit] so the workflow ensures lockfile-audit finishes (and fails early on invalid/malicious lockfile) before running the lint, test, or build jobs.
14-14: ⚡ Quick winAdd explicit permissions for the supply-chain audit job.
Static analysis flags missing permissions. For a security-focused job, declaring minimal permissions reduces blast radius if the job were compromised.
🔒 Proposed fix to add permissions
lockfile-audit: name: Lockfile Audit runs-on: ubuntu-latest + permissions: + contents: read steps:🤖 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/test.yml at line 14, The lockfile-audit job is missing an explicit permissions block; add a minimal permissions: mapping under the job named "lockfile-audit" to declare least-privilege access for the supply-chain audit (e.g., at minimum give contents: read and any tool-specific scopes required such as security-events: write or id-token: write), ensuring you only include the exact scopes the audit action needs; update the workflow so the lockfile-audit job contains a top-level permissions: section with those minimal entries.
🤖 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/test.yml:
- Around line 18-19: Update the Checkout step that currently uses
actions/checkout@v4 to use a pinned commit SHA instead of a floating tag and add
persist-credentials: false to the step; find the step with name "Checkout" and
the uses value "actions/checkout@v4" and replace the tag with the specific
commit SHA for actions/checkout and add the persist-credentials: false input to
the step, and then apply the same pin+persist-credentials change consistently to
all other checkout steps in the workflow to avoid inconsistency.
- Around line 14-16: Add an explicit dependency on the lockfile-audit job so
downstream jobs don’t run installs before the audit completes: update the lint,
test, and build job definitions to include needs: [lockfile-audit] so the
workflow ensures lockfile-audit finishes (and fails early on invalid/malicious
lockfile) before running the lint, test, or build jobs.
- Line 14: The lockfile-audit job is missing an explicit permissions block; add
a minimal permissions: mapping under the job named "lockfile-audit" to declare
least-privilege access for the supply-chain audit (e.g., at minimum give
contents: read and any tool-specific scopes required such as security-events:
write or id-token: write), ensuring you only include the exact scopes the audit
action needs; update the workflow so the lockfile-audit job contains a top-level
permissions: section with those minimal entries.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6ad47968-30b9-44a9-b606-2ca8e66f8edb
📒 Files selected for processing (1)
.github/workflows/test.yml
What
Adds a
Lockfile AuditCI job that fails ifpnpm-lock.yamlcontains:http://resolutions, orgit/tarball/directorysources (registry-bypass).Why
Closes the lockfile-validation gap (practices #6–8 of the supply-chain baseline).
lockfile-lintonly supports npm/yarn lockfiles — it errors on pnpm withUnable to find relevant lockfile parser for type "pnpm"— so this asserts the same invariants directly. Package integrity (SHA-512) and lockfile/manifest drift are already enforced bypnpm install --frozen-lockfilein the existing jobs.Verification
Ran the gate locally against the current lockfile:
pnpm-lock.yaml OK(0 insecure, 0 exotic), exit 0. YAML lints clean.Summary by CodeRabbit