Repository navigation
feat: reject unreviewed dependency sources in the pnpm lockfile - #499
Closed
seuninfoo-svg wants to merge 1 commit into
Closed
seuninfoo-svg wants to merge 1 commit into
seuninfoo-svg wants to merge 1 commit into
Conversation
|
@seuninfoo-svg Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #493
PR: Static pnpm-lock.yaml Source-Policy Checker
Summary
Add a static lockfile source-policy checker that validates all dependency sources in
pnpm-lock.yamlagainst a strict allowlist. This prevents supply-chain risks from unreviewed dependency sources (Git URLs, local paths, plain HTTP, unexpected tarball hosts) before any installation occurs.Problem
A lockfile can introduce dependencies from:
git:,git+ssh:,git+https:,github:,gitlab:,bitbucket:)file:,link:)http:)Even when
package.jsonmanifests look normal, transitive dependencies or resolution overrides can pull from these sources. A small policy check makes these sources reviewable beforepnpm install.Solution
Created
scripts/check-lockfile-sources.mjs— a zero-dependency (besides existing logging package) static analyzer that:pnpm-lock.yaml(YAML → custom lightweight parser, no new deps)importers(specifier + resolved version) andpackages(keys + resolution objects)Default Policy
https:to npm registriesregistry.npmjs.org,registry.yarnpkg.com,registry.npmmirror.com,codeload.github.comworkspace:link:in version fieldworkspace:*→link:git:,git+ssh:,git+http:,git+https:github:,gitlab:,bitbucket:ssh:file:link:(non-workspace)http:Allowlist
ALLOWLIST_HOSTSset (initially empty) for exceptional hosts — add with explicit justification.Files Added
Files Modified
package.json— Addedlockfile:sources:checkandlockfile:sources:testscriptsUsage
Example Output
Clean Lockfile
Violations
Test Coverage
passes for valid lockfilefails for git dependencygithub:shorthand rejectedfails for git+ssh dependencygit+ssh:rejectedfails for file: dependencyfile:rejectedfails for http: dependencyfails for external link: dependencylink:rejectedallows workspace: specifierworkspace:*allowedallows link: in version fieldallows HTTPS from npm registryprints sanitized identifiersIntegration
Runs before dependency installation in CI:
No network access — purely static analysis of committed
pnpm-lock.yaml.Design Decisions
js-yamldependency; parser targets pnpm v9 lockfile structure onlyspecifier(user intent) +version(pnpm resolution) — Catches both manifest and resolved sources{ tarball: "...", gitHosted: true }on single linegit+ssh://git@host/...→git+ssh://host/...)@sub-rosa/logging— Consistent JSON diagnostics