insanitybit / cargo-sandbox

MIT License
112 stars 2 forks source link

cargo-sandbox add #13

Open insanitybit opened 1 year ago

insanitybit commented 1 year ago

This might not be the right place for a cool cargo add implementation, but something I've long wanted is for cargo add to check for typosquatting. Simplest way to do this is:

  1. Keep an index of all published crates
  2. When cargo add foobar is executed check for typosquatting against the index. A naive approach would just be to check the string edit distance but that could be refined. Reputation could be used as an additional heuristic, like "foo-bar looks similar to the more popular crate foobar, are you sure you want to add this dependency?"

It could be behind a config value and off by default to avoid breaking changes.