News for hackers. Stuff that matters.
Re:Malicious code in the purescript NPM installer by geofft on Sunday July 28, 2019 @05:07PM (#20549843)
Perl (cpan), Python (pip or conda), Ruby (gem), and Rust (cargo) all behave as NPM does, so that doesn't seem to be the explanation here.
Re:Malicious code in the purescript NPM installer by adev_ on Monday July 29, 2019 @03:29AM (#20552237)
> Perl (cpan), Python (pip or conda), Ruby (gem), and Rust (cargo) all behave as NPM does

Wrong.

None of them have chosen the "micro-package" way of NPM.

None of them have an average size of "3-10" line of code per package, which NPM has for many MANY packages. Cargo, pip have many packages but "reasonnable size" packages. ( > 100 lines ).

The Micro-package philosophy that NPM chose, meaning every single line of code can have its own package, increase by several factor the number of dependencies required to create anything in JS.

A simple hello world in react already have ~100 dependencies

https://npm.anvaka.com/#/view/2d/react-create-app

Some core utility bundler/packer/etc overpasses 2000 dependencies

https://npm.anvaka.com/#/view/2d/webpack

This is madness.

It is a simple evidence that bigger the dependency tree is, higher the chance of "one element" malicious / corrupted is.

Maybe the NPM developpers / users should reflect on what lead to this situation instead of closing their eyes and sing "everything is fine".

Re:Malicious code in the purescript NPM installer by geofft on Monday July 29, 2019 @12:38PM (#20556463)
Nobody is closing their eyes and singing "everything is fine." A large number of small packages is a good thing, and a technically strong ecosystem supports it. Having spent the last week in the internals of glibc chasing bugs in code that has no reason to be jammed into the same library that handles initial program loading, I can attest that there are good, justifiable, technical reasons to do things the NPM way, and I'm glad that there are smart, qualified, talented people implementing that.

I know it's hard for you to imagine, but perhaps the JavaScript ecosystem has some good things about it.

Re:Malicious code in the purescript NPM installer by adev_ on Monday July 29, 2019 @02:31PM (#20557765)
> I know it's hard for you to imagine, but perhaps the JavaScript ecosystem has some good things about it.

There is good in very ecosystem. But a simple keyword "node_modules" on twitter should probably convince you that the good of JS is not in its package system.

To be fair, even the NodeJS author agree on that.

Modularity does not mean "split your code at the atomic level".

Re:Malicious code in the purescript NPM installer by akamaozu on Tuesday July 30, 2019 @01:53AM (#20562409)
JavaScript's package manager is a massive plus to the ecosystem.

The language would not be worth using without it.

Re:Malicious code in the purescript NPM installer by m90 on Monday July 29, 2019 @03:51AM (#20552368)
> None of them have chosen the "micro-package" way of NPM.

This is not something inherent to npm itself, it's what the people using npm choose to publish.

No matter if people like small modules or not, it's not at all related to the topic discussed.

Re:Malicious code in the purescript NPM installer by adev_ on Monday July 29, 2019 @04:05AM (#20552444)
> No matter if people like small modules or not, it's not at all related to the topic discussed.

It is very relevant to the topic discussed.

Just for fun :

https://npm.anvaka.com/#/view/2d/purescript

> 150 dependencies.

Including a package named "one-time", bundled several times in two different versions. To do something highly relevant and technical like "Call a function once".

I have no doubt that it is an Highly complex code that requires indeed two packages..... Irony

Little question: What would have been the probability of purescript getting malicious if its dependency tree would be something reasonnable... Let's say 20 packages instead of the current ~200 ?

Re:Malicious code in the purescript NPM installer by stephenr on Monday July 29, 2019 @04:33AM (#20552583)
Thank you for linking to that dependency grapher.

The crab-grass like dependencies of many/most NPM packages is scary enough, and then they (or you?), I guess because of lazy loading, to improve responsiveness, update it as you watch.. It's like a scene out of an alien monster movie, where the creature keeps growing more limbs.

Re:Malicious code in the purescript NPM installer by wdroz on Monday July 29, 2019 @03:04AM (#20552125)
conda use namespaces (called channels). If you want a package from a random person, you've to explicitly add it (either globally or when installing the package).
Re:Malicious code in the purescript NPM installer by Fellshard on Sunday July 28, 2019 @09:12PM (#20550768)
That is why I cited the behaviour and culture of JavaScript-only devs as the primary explanation, with NPM's model reinforcing those issues - issues that do not exist in the same manner in those other languages' ecosystems and cultures.
Re:Malicious code in the purescript NPM installer by twic on Sunday July 28, 2019 @05:16PM (#20549883)
cargo, at least, does this for the reason Fellshard gives - the Rust team essentially commissioned a copy of Ruby's bundler, without considering whether there was anything to learn from any other language's ecosystem.
Re:Malicious code in the purescript NPM installer by geofft on Sunday July 28, 2019 @05:19PM (#20549896)
Well, okay, if your point of view is that behaving like multiple other major languages and specifically taking the lessons (good and bad) of a specific existing language ecosystem into account before doing your own thing is the same as disregarding other languages and reinventing the wheel, I'm not sure what words mean anymore.
Re:Malicious code in the purescript NPM installer by twic on Monday July 29, 2019 @05:19AM (#20552771)
> Well, okay, if your point of view is that behaving like multiple other major languages and specifically taking the lessons (good and bad) of a specific existing language ecosystem into account before doing your own thing is the same as disregarding other languages

If you've only looked at two or three languages that not coincidentally happen to do things pretty much the same as each other, and not looked elsewhere, then you are indeed disregarding other languages.

> and reinventing the wheel

I didn't mention reinventing the wheel.

> I'm not sure what words mean anymore.

Agreed, but i'm not sure i can help you with that.

Re:Malicious code in the purescript NPM installer by steveklabnik on Sunday July 28, 2019 @09:57PM (#20550933)
Cargo is more like npm than Bundler in this regard, as Bundler does not let you have multiple versions of a package at the same time. That lesson was learned from npm, though implemented in a different way.
Re:Malicious code in the purescript NPM installer by kibwen on Sunday July 28, 2019 @06:47PM (#20550245)
Namespaces would be a feature of Crates.io, not Cargo (and Crates.io was not contracted to Yehuda Katz, as Cargo was).
Re:Malicious code in the purescript NPM installer by twic on Monday July 29, 2019 @05:21AM (#20552786)
How so? Do you mean that Cargo would support crates with names like "example/foo" or "org.example/foo", but that's just not how Crates.io works?

If so, that's interesting, but then my question is why we didn't make use of that.

Re:Malicious code in the purescript NPM installer by steveklabnik on Monday July 29, 2019 @12:04PM (#20556017)
There's a few different elements of the design space. But, while Cargo can use crates.io, it's distinct from it, so on first principle, this would be a crates.io feature.

That being said, Cargo would also have to understand it, because the Rust language does not understand namespaced external packages, so you'd either have to change the language, or change Cargo to do something to paper over that somehow.

As for "why didn't we do this in the first place with crates.io", https://internals.rust-lang.org/t/crates-io-package-policies... lays out some of this background, though not all of it.

Re:Malicious code in the purescript NPM installer by twic on Monday July 29, 2019 @12:44PM (#20556543)
Thanks for the reference!

> When we looked at package ecosystems without namespacing, we found that people tended to go with more creative names (like nokogiri instead of “tenderlove’s libxml2”). These creative names tend to be short and memorable, in part because of the lack of any hierarchy. They make it easier to communicate concisely and unambiguously about packages. They create exciting brands.

I will never stop admiring your ability to see the bright side of things.