Repository navigation
Commit 8bbd70d
authored
fix(arborist): allow-remote exemption for proxy/mirror-fronted registry tarballs (#9550)
With `allow-remote=none` (the default on npm 12) or `allow-remote=root`,
a `npm install` fails with `EALLOWREMOTE` on ordinary registry
dependencies when the configured registry origin differs from the
lockfile `resolved` origin.
```
npm error code EALLOWREMOTE
npm error Fetching packages of type "remote" have been disabled
```
This is the common proxy/mirror case: a committed `package-lock.json`
whose `resolved` URLs point to `https://registry.npmjs.org/...`, while
the machine (or CI) is configured to use a private registry proxy/mirror
with a different origin.
It affects both the hoisted and the linked install strategy.
## Why
When extracting a registry-resolved package, reify hands pacote a
`name@URL` spec, which pacote re-parses as `type=remote` and gates with
allow-remote.
To avoid mis-firing on registry tarballs, `#isRegistryResolvedTarball`
exempts them — but it compared the raw lockfile `resolved` URL against
the configured registry origin.
With a proxy/mirror configured, `resolved` is the canonical
`registry.npmjs.org` URL while the configured registry is the proxy, so
the origins never matched, the exemption returned `false`, and the
registry tarball was rejected as remote.
Crucially, reify already fetches a different URL than the raw
`resolved`: `#registryResolved` applies `replace-registry-host` (default
`npmjs`), rewriting the `registry.npmjs.org` host to the configured
registry while preserving the path.
So npm fetches the tarball from the proxy correctly; only the
allow-remote check was evaluating the wrong (pre-rewrite) URL.
## How
Evaluate the effective URL npm actually fetches, not the raw lockfile
value.
`#isRegistryResolvedTarball` now parses
`this.#registryResolved(node.resolved)` — the host-rewritten URL —
before the same origin + registry-path-prefix comparison.
After rewriting, a public-registry-pinned tarball resolves to the
configured registry and is correctly recognized as registry-mediated.
The existing security boundary is preserved: under the default
`replace-registry-host`, a same-origin tarball pointing outside the
registry path is not rewritten and is still rejected, and a genuinely
URL-declared dependency still fails the `node.isRegistryDependency`
guard.
Under `replace-registry-host=always`, every tarball is routed through
the configured registry, so registry dependencies are no longer treated
as remote — consistent with what `always` means.
## References
Fixes #95481 parent 315e3bd commit 8bbd70d
2 files changed
Lines changed: 105 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
908 | | - | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
909 | 911 | | |
910 | 912 | | |
911 | 913 | | |
912 | | - | |
913 | | - | |
| 914 | + | |
| 915 | + | |
914 | 916 | | |
915 | 917 | | |
916 | 918 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3914 | 3914 | | |
3915 | 3915 | | |
3916 | 3916 | | |
| 3917 | + | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
| 3965 | + | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
| 3977 | + | |
| 3978 | + | |
| 3979 | + | |
| 3980 | + | |
| 3981 | + | |
| 3982 | + | |
| 3983 | + | |
| 3984 | + | |
| 3985 | + | |
| 3986 | + | |
| 3987 | + | |
| 3988 | + | |
| 3989 | + | |
| 3990 | + | |
| 3991 | + | |
| 3992 | + | |
| 3993 | + | |
| 3994 | + | |
| 3995 | + | |
| 3996 | + | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
| 4010 | + | |
| 4011 | + | |
| 4012 | + | |
| 4013 | + | |
| 4014 | + | |
| 4015 | + | |
| 4016 | + | |
3917 | 4017 | | |
3918 | 4018 | | |
3919 | 4019 | | |
| |||
0 commit comments