You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add npm approve-scripts, npm deny-scripts, and the npm install-scripts approve/deny/list/prune workflow for reviewing dependency lifecycle scripts.
Match and write policy entries from trusted resolver identities for registry, remote tarball, git, file, and linked-store dependencies instead of package-controlled manifest fields or internal .store paths.
Preserve deny-wins behavior across equivalent file paths and linked installs while retaining compatibility with existing file policy spellings.
Dereference and deduplicate linked targets, retain link names as selectors, and support exact source selectors for ambiguous dependencies.
Keep exact git selectors commit-aware, honor linked-store registry denies, and allow an explicitly selected identity to approve multi-link file targets.
Document source-specific approval, denial, listing, pruning, and pinning behavior.
Regression coverage
Registry identity and alias trust boundaries, remote URL exactness, hosted git commits, local path equivalence, and malformed sources.
Linked install/store identities, deny-wins behavior, exact selectors, ambiguous names, multiple link identities, and pruning.
Rebuild/reify lifecycle enforcement and command output for approve, deny, list, and JSON modes.
Validation
Full @npmcli/arborist tests pass locally with 100% statements, branches, functions, and lines; lint and postlint pass.
Full @npmcli/config and docs workspace tests, lint, and postlint pass locally.
Focused root approve/install/writer tests and root lint pass locally.
Use trusted resolver and lockfile identities for remote, git, file, and linked dependencies. Keep approval, denial, warnings, documentation, and policy matching consistent without treating canonical physical paths as equivalent identities.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9a58801a-1dff-40d8-b74c-b21545984d73
This PR updates npm’s install-script approval workflow to use trusted dependency source identities, addressing remote-tarball approvals reported in #9738.
Changes:
Updates source matching and policy writing for remote, git, file, and linked dependencies.
Adds source-aware selectors, ambiguity checks, and clearer pending-script output.
Expands regression coverage and documents source-specific approval, denial, and pinning.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
File-source handling blocks approval and denial of linked-install tarball targets and hides the exact selectors needed for targets with multiple trusted file identities.
Expose multiple trusted file identities in listings and errors
lib/utils/allow-scripts-cmd.js:61
For a target with multiple trusted file identities, versionedKeyFor() returns null, so ls prints [untrusted source] and JSON exposes only the bare name. Approving that name then fails with ENOMATCH, leaving the supported exact selectors undiscoverable through the documented workflow. Show the choices from filePolicyIdentities(node) in listings and in the error when bare-name approval cannot choose one identity.
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
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.
Summary
npm approve-scripts,npm deny-scripts, and thenpm install-scriptsapprove/deny/list/prune workflow for reviewing dependency lifecycle scripts..storepaths.Regression coverage
Validation
@npmcli/arboristtests pass locally with 100% statements, branches, functions, and lines; lint and postlint pass.@npmcli/configand docs workspace tests, lint, and postlint pass locally.Fixes #9738.
Draft intentionally while the refreshed CI matrix completes.