Repository navigation
feat: reject unreviewed dependency sources in the pnpm lockfile - #559
Open
seuninfoo-svg wants to merge 1 commit into
Open
seuninfoo-svg wants to merge 1 commit into
seuninfoo-svg wants to merge 1 commit into
Conversation
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.
PR: Add pnpm Lockfile Source Policy Checker
Summary
Implements a static
pnpm-lock.yamlsource-policy checker that rejects dependencies from untrusted sources (git, file:, link:, plain HTTP, unknown registries) before installation. This mitigates supply-chain risks where a lockfile could introduce dependencies from Git URLs, local paths, or unexpected tarball hosts even when package manifests look normal.Motivation
A lockfile can introduce dependencies from:
git+https://,git+ssh://)file:../local-package)link:/absolute/path,link:./local-dep)http://registry.example.com/pkg.tgz)Even when
package.jsonmanifests specify only registry versions, transitive dependencies or lockfile manipulation can introduce these sources. This checker makes such sources reviewable via an explicit allowlist.Changes
New Files
scripts/check-lockfile-sources.mjsscripts/check-lockfile-sources.test.mjsconfig/lockfile-allowlist.jsonModified Files
package.jsonlockfile:check,lockfile:test,preinstall,install:checkscripts; addedyamldev dependencyscripts/check-logging.mjsconsolefor CLI output)Acceptance Criteria
All criteria from the issue are satisfied:
checkPackageResolution()+checkImporters()registry.npmjs.org,registry.yarnpkg.com,registry.npmmirror.comconfig/lockfile-allowlist.jsonwith JSON schema commentpreinstallscript + manualinstall:checksanitizeUrl()strips user:pass@ from outputpnpm-lock.yamlandlockfile-allowlist.jsonUsage
Manual Check
Pre-Install (CI / Local)
Allowlisting Exceptional Hosts
Edit
config/lockfile-allowlist.json:{ "allowlist": ["github.com", "npm.pkg.github.com", "registry.internal.company.com"] }Subdomains are automatically allowed (e.g.,
github.compermitsraw.githubusercontent.com).Test Coverage
Example Output
Violations Found
Clean Lockfile
Design Decisions
github.compermitsapi.github.com,raw.githubusercontent.com, etc.https://github.com/...nothttps://token@github.com/...link:../../packages/...passes;link:./localandlink:/absolutefailyamlpackage - Node.js lacks built-in YAML parser;yamlis a well-maintained, zero-dependency libraryCI Integration
Add to CI pipeline (e.g.,
.github/workflows/ci.yml):Related
config/lockfile-allowlist.json(schema comment)close #493