4 ms·
This has really been bugging me about npm. Anyone can publish a open source repo and add it to npmjs. Users going to the page on npmjs will see that the repo w
by sam_goody 3y ago
This has really been bugging me about npm.
Anyone can publish a open source repo and add it to npmjs. Users going to the page on npmjs will see that the repo with the code is github.com/myrepo.
But when I do `npm i myrepo` there is no guarantee that what is being pulled is in any way similar to what is in the linked repo. Creating a false feeling that the code could be reviewed.
At the very least, Github should not allow this for code on their platform (ie, if npmjs has it listed as the repo of a project they should scan that the project actually builds to the content or notify npm who should have it flagged). Or npmjs should regularly scan the same - checking that the code you would get by compiling matches the code being offered
Bear in mind that if a bad actor can get in at the level of the NPM user, even if the user is not running with elevated privileges (which it often is since you need to be a superuser to listen on port 80 or to read SSL certificates, and PM2 with handling for SSL is way above the ability of many devs, sigh), they can scan for vulnerabilities, and perhaps open themselves a very big hole.
- 3np 3y agoFYI: `npm publish` reports the current commit hash, if any, and this is publically viewable from the npm registry. This should help audit/verify if publishers have published what they say and if builds are reproducible. E.g. $ curl -sL https://registry.npmjs.com/colors | jq -r '.versions|map([.version, .gitHead]|@tsv)|.[]'
- PaoloBarbolini 3y agoSame for Rust. In the short term we're trying to solve it on the user's side with https://crates.io/crates/cargo-goggles https://crates.io/crates/cargo-goggles, but in the long term the registry should probably do it.
- pabs3 3y agoAre crate maintainers going to accept having to do this? I've seen crates where the code in the crate was generated by a Python script not in the crate but only in git.
- bdd8f1df777b 3y agoAh, I was wrong assuming that npm is cloning every git repo of the dependencies.