Commit 4bcba54
authored
fix(arborist): apply registry-tarball allow-remote exemption in linked strategy (#9495)
In continuation of our exploration of using `install-strategy=linked` in
the [Gutenberg
monorepo](WordPress/gutenberg#75814), which
powers the WordPress Block Editor.
Under `install-strategy=linked`, a fresh install fails with
`EALLOWREMOTE` on ordinary registry dependencies whose lockfile
`resolved` is a full registry tarball URL, even though
`allow-remote=none` is meant to permit registry-mediated tarballs. The
standard (hoisted) reifier installs the same dependency fine; only the
linked strategy rejects it.
```
npm error code EALLOWREMOTE
npm error Fetching packages of type "remote" have been disabled
npm error Refusing to fetch "minimatch@https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz"
```
## Why
Both strategies extract through the same `pacote.extract` in `reify.js`,
which exempts registry tarballs from the allow-remote gate via
`#isRegistryResolvedTarball`. That check first requires
`node.isRegistryDependency`. In the linked strategy, store nodes are
`IsolatedNode` instances — a standalone class that emulates
`lib/node.js` but has no `isRegistryDependency` getter and no edges to
recompute it from. So `node.isRegistryDependency` was `undefined`, the
exemption short-circuited to `false`, the `allowRemote: 'all'` override
was never applied, and pacote rejected the same-origin registry tarball.
This is the second half of the allow-remote registry-tarball handling:
the URL-matching half was hardened previously (origin +
registry-path-prefix); this fixes the `isRegistryDependency` half for
the linked path. The origin/path security check still runs unchanged on
the linked path — a tampered lockfile pointing at a foreign host is
still blocked.
## How
Carry the registry-dependency flag from the source tree node onto the
store node, rather than weakening the guard:
1. `IsolatedNode` gains an `isRegistryDependency` field (default
`false`), settable from constructor options.
2. `#externalProxy` copies `node.isRegistryDependency` from the real
tree node onto the proxy.
3. `#generateChild` passes it through to the store `IsolatedNode`.
This preserves exact parity with the hoisted reifier: registry deps are
exempt, user-pinned off-registry URLs are not. It also makes the linked
strategy's `isScriptAllowed` matching more accurate — store nodes now
carry the trustworthy edge-based flag instead of falling back to
guessing registry-ness from the resolved URL.
## References
Fixes #94941 parent 0e55f97 commit 4bcba54
4 files changed
Lines changed: 59 additions & 0 deletions
File tree
- workspaces/arborist
- lib
- arborist
- test
- arborist
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
156 | 160 | | |
157 | 161 | | |
158 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3854 | 3854 | | |
3855 | 3855 | | |
3856 | 3856 | | |
| 3857 | + | |
| 3858 | + | |
| 3859 | + | |
| 3860 | + | |
| 3861 | + | |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
| 3868 | + | |
| 3869 | + | |
| 3870 | + | |
| 3871 | + | |
| 3872 | + | |
| 3873 | + | |
| 3874 | + | |
| 3875 | + | |
| 3876 | + | |
| 3877 | + | |
| 3878 | + | |
| 3879 | + | |
| 3880 | + | |
| 3881 | + | |
| 3882 | + | |
| 3883 | + | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
| 3887 | + | |
| 3888 | + | |
| 3889 | + | |
| 3890 | + | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
| 3900 | + | |
| 3901 | + | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
| 3905 | + | |
| 3906 | + | |
3857 | 3907 | | |
3858 | 3908 | | |
3859 | 3909 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| 455 | + | |
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| |||
0 commit comments