-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RRFC] Improve experience and security around npx and scoped packages #323
Comments
I am pretty much 👍 on all of this. I am sure there are details to work out, but I also imagine the recommendation will be to split this up so it is easier to discuss each feature on it's own.
This one is a big deal which we have discussed before, the fact that multiple packages defining the same |
That's entirely orthogonal to "scopes" tho, as any two unscoped packages can have the same issue, no? |
Yes, but if I read the docs correctly, you'd only reach the cli which does not match package name via --package explicitly, so that's fine, I think. |
right but i could make a package that provides a bin that matches the package and also eslint, and if my package was installed I’d nondeterministically hijack eslint. |
I'm not sure if that's breaking or not, but maybe Specifying a stricter, deterministic |
👋 anything I can do help move this forward? |
Motivation ("The Why")
Some of those were requests/issues even with the old
npx
that didn't get much attention.Despite reporting multiple issues in here, I figure they are all somewhat related and probably need to be considered in context of each other.
Examples
npx @scope/cli
could not determine executable to run
cli
(or the only existing) bin from the@scope/cli
package. This actually works with thenpx
innpm@6
.npm exec
works internally... if it's just looking for something that's linked into.bin
, then maybe there's quite an amount of work involved, but nevertheless - having this feature, and having it be strict, is a primary fix for any spoofing attacks.another-command
to always be used from@scope/cli
--package
option:npx another-command -p @scope/cli
.npmrc
the user can callnpx another-command
without providing the-p @scope/cli
--package
to current foldercd [path to @scope/cli] && npx @scope/cli
(ornpx another-command
even) would fail, unless@scope/cli
is a dependency of itselfpackage.json
(or a parent folder has apackage.json
, and thatpackage.json
exposes somebin
s - I'd like tonpx
those bins, rather than something that still needs to be installed.scripts
as well asbin
and remember to usenpm run
, instead ofnpm exec
.npm i -g .
, but it would still be nice to get this.npx cli
will execute acli
from@scope/cli
if it is installednpx cli
should only execute@scope/cli
if@scope
is explicitly allowed via some configuration to use shorthand commands, i.e. the user should explicitly tell where to look for the bin either via config, or via--package
, or via the first thing suggested here (i.e. scoping the command call itself).cli
when it is installed from multiple scopescli
and@scope/cli
are installed, callingnpx cli
will executecli
@scope/cli
comes from my private registry, andcli
comes from a deep public dependency, I definitely do not wantcli
to execute -npx
should probably force me to provide a--package
when there's any ambiguity (or usenpx @scope/cli
once that is supported)References
The text was updated successfully, but these errors were encountered: