Live data from Hacker News

NPMprune: Remove unnecessary files from node_modules to optimize storage

github.com

51–52 of 52 posts

Re: NPMprune: Remove unnecessary files from node_modules to optimize storage

#51
post #11

> In deployment scripts: > > wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master... | sh -- -p Serious question: Is this the norm now? Are people actually executing unversioned wget'd shell scripts from random github users as part of their deployment workflow?

The threat model is exactly the same as executing untrusted, uninspected content you've downloaded locally. I could do some tricks where I sent different files based on user agent, but still... most people aren't inspecting the download anyway before running it.

It's been demonstrated that the server can tell if the client is piping or not

https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...

I'm on mobile and this refuses to load due to SSL/HSTS problems. It's an interesting approach if you can get it to load.

Point being... someone clever could make a bad day for the minority of users who do check first (but don't save/run what they explicitly checked)

Running curl, saying "yup that looks good", then adding a pipe achieves little with actual malice. The payload can be completely hidden until it's too late

The phrasing you use is important for any hope at safety - review/run the same downloaded thing.

Re: NPMprune: Remove unnecessary files from node_modules to optimize storage

#52
post #8

This is wildly unsafe. - Some packages contain non-JS files for good reasons, and they may break in subtle unpredictable ways when you mess with the contents of their package. - Node.js will happily run JavaScript files even if they're not "*.js": A file like "hello.alsdfhlshdfl" works just fine as long as its content parses. There is no guarantee that your dependencies (and their recursive dependencies) don't static…

- Of course, this entails the risk of occasional breakage. But for 99% of modules, this has no impact at runtime. - The patterns used to find files are specific enough to target only those files that are well known to be useless at runtime. - The license texts of these libraries can be copied and merged into a main LICENSE file. - Have you seen the number of modules installed by most major libraries? Making a pull re…

> But for 99% of modules, this has no impact at runtime.

> Have you seen the number of modules installed by most major libraries?

Chances of success, negligible.

Translation: take 99% to the power of 'a lot' and what do you get?

Post reply on HN