Replies: 6 comments 17 replies
-
Yarn v2 has a similar feature using |
Beta Was this translation helpful? Give feedback.
-
I would like to see some solution like hashes for scripts (only hash Something similar like the SRI hashes in browsers. People also wanted this feature in Deno but it looks like it was never implemented: denoland/deno#200 |
Beta Was this translation helpful? Give feedback.
-
Another recommendation: please enforce 2FA for all my packages when I setup 2FA for my npm account. I have to do this manually for every single package. |
Beta Was this translation helpful? Give feedback.
-
I'm guessing this would help against npm packages executed only in the browser. But for packages running in node, they still have disk access + can execute on the shell, no? So in that later case shutting down scripts wouldn't help much? |
Beta Was this translation helpful? Give feedback.
-
#488 is another proposal related to this. It changes the default behavior of install scripts. Note that I've updated the |
Beta Was this translation helpful? Give feedback.
-
For semantic reasons I would recommend the usage of Thanks for the RFC @koba04 |
Beta Was this translation helpful? Give feedback.
-
What / Why
install
andpostinstall
are npm scripts that run whilenpm install ${package}
ornpm ci
.It means that we allow the package author to run any scripts on our machine, which is definitely dangerous if we don't recognize what packages are installed as dependencies.
Unfortunately, it might be impossible to recognize all the dependencies on your project so we run scripts we don't know while
npm install
.To avoid this, we can use the
--ignore-scripts
option, which disables all npm scripts while installing dependencies.But sometimes the scripts are required to work the packages.
I've created an npm package to print all these scripts in your project.
https://github.com/koba04/install-scripts
But I think it would be nice if npm has the mechanism to opt-in
install
andpostinstall
scripts.I guess there are some ways to do this. The followings are ideas on me. Please let me know If you have any ideas 🙏
allowedScripts
inpackage.json
This field is to allow packages to run npm scripts.
With this option, we can share the information that we allow packages to run scripts through the package.json.
It might be better this option is enabled only with
--allowed-scripts
option.--confirm-scripts
This option is to show a prompt whether you run the script or not.
This is useful if you know what the script would do.
other option
This is another feature request for
--ignore-scripts
.I hope that npm prints all scripts not to run while installing with
--ignore-scripts
like https://github.com/koba04/install-scripts.When
npm install
ornpm ci
Where
How
Current Behavior
install
andpostinstall
scripts or don't run any scripts with--ignore-scripts
option.Expected Behavior
Who
References
Beta Was this translation helpful? Give feedback.
All reactions