fix(libnpmexec): honor min-release-age-exclude when resolving specs - #9944
Open
MrRio wants to merge 2 commits into
Open
fix(libnpmexec): honor min-release-age-exclude when resolving specs#9944MrRio wants to merge 2 commits into
MrRio wants to merge 2 commits into
Conversation
npx resolves its requested spec with pacote.manifest directly, passing flatOptions.before (set by min-release-age) straight through. pacote has no knowledge of min-release-age-exclude, so packages matching an exclude pattern were still rejected with ETARGET/ENOVERSIONS. Reuse arborist's release-age-exclude helper (the same logic npm install applies per-spec) to drop the before cutoff when the spec's trusted name matches an exclude pattern. Fixes: npm#9765
Author
|
@martinrrm would you be able to take a look at this as an approach? Making things tricky for our users without it as we want to protect them from supply chain attack risk |
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.
Description
npxresolves its spec withpacote.manifest, forwardingflatOptions.before(set bymin-release-age). pacote knows nothing aboutmin-release-age-exclude, so excluded packages still failed withETARGET.npm installisn't affected because arborist dropsbeforeper-spec for exempted names.This matters because it undermines the release-age protection itself:
min-release-age-excludeexists so teams can keep a strict age window on third-party packages while still running their own trusted packages immediately. Withnpxignoring it, the only workaround is--min-release-age=0, which turns the supply-chain safeguard off for the entire transitive tree instead of just the one exempted package.This makes libnpmexec do the same before calling
pacote.manifest, reusing arborist'srelease-age-exclude.jshelper (isReleaseAgeExcluded+trustedSpecName, sonpm:alias keys can't exempt the package they resolve to). The deep require follows the existing pattern instrict-allow-scripts-preflight.js; no new dependencies. The install into the npx cache already goes through arborist, so only the direct manifest lookup needed fixing.Testing
Two tests added to
workspaces/libnpmexec/test/registry.js: an excluded spec resolves and runs despite a pastbeforecutoff (fails withENOVERSIONSwithout the fix), and a non-excluded spec is still blocked.Verified manually from this checkout against the public registry, using a package version published inside the age window (
pnpm@11.25.0, published 2026-08-29):Before this change, the exclude pattern is ignored:
After this change, the same command resolves and runs:
The filter itself still applies — dropping
--min-release-age-excludefrom the command above still fails withETARGETafter this change.Fixes #9765
Alternative to #9768 — reuses arborist's helper instead of duplicating the minimatch logic in libnpmexec.