Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for typos. #172

Closed
Eh2406 opened this issue Oct 12, 2017 · 6 comments
Closed

Check for typos. #172

Eh2406 opened this issue Oct 12, 2017 · 6 comments

Comments

@Eh2406
Copy link

Eh2406 commented Oct 12, 2017

Hi,

So in the recent discussion of the problems on the npm-malicious-packages and the problems on Python typosquatting I bilt a quick script for looking for typos. I think the python community added tools for checking if the packages you are using are similar to much more popular packages.

I was thinking of making a cargo-utill somehow based on my quick script. I started by looking at cargo-edit for info on how to read the toml, handle workspaces, do testing, etc.. But at this point it may as well be a part of cargo-edit.

Thoughts?

@killercup
Copy link
Owner

killercup commented Oct 12, 2017 via email

@Eh2406
Copy link
Author

Eh2406 commented Oct 12, 2017

Thanks for the +1, just some notes as I dig in.

Looks to me like get_latest_dependency is where add talks to the internet and I'd prefer to add as few trips to the internet as possible. If we add this functionality there then it becomes part of both add and upgrade.

I want an example to test with. I think request should suggest reqwest. Unfortunately the search on the website for request does not find reqwest. So just checking the search api won't help. If we are going to need to get a list of all the names than using the web api's are not going to work. (Unless we get them to add one, but that seems like a big job.)

My original script used a checkout of crates.io-index to get all the names. But that is somewhat wasteful as cargo keeps a copy at "%CARGO_HOME%\registry\index\github.com-0somehash4` so maybe we can read it from there, no trips to the internet required. We would need to determine the exact path and sutch. edit: looks like the code is in https://github.com/rust-lang/cargo/tree/master/src/cargo/sources/registry

@killercup
Copy link
Owner

killercup commented Oct 13, 2017 via email

@ordian
Copy link
Collaborator

ordian commented Oct 13, 2017

I'd hoped crates.io would have the right kind of fuzzy search for that in
place. Maybe it makes sense to also open an issue on their tracker as well?
The crates.io search could benefit from this as well.

Maybe this issue is relevant rust-lang/crates.io#1074?

@Eh2406
Copy link
Author

Eh2406 commented Oct 13, 2017

@ordian that looks very relevant thanks for the link! If they want to add an API we should use it!

@killercup

Let's get a general implementation plan in place before writing a lot of
code :)

No worries, no code has been harmed written in my digging in. From you response we are on smaller wavelengths. I to want to keep this code snappy.

As to doing it ourselves, that is what I was thinking. I don't know of a way to get cargo to give the path to the index. (there is a library for querying it, but it is maintained separately and somewhat out of date.) Maybe we should talk to the cargo people, about adding a sub command or moving there code to a library? Updating cargos index is not a snappy operation, but if you just used add than it is the next thing cargo is going to do anyway. I think it should just be a warning like, Looking up request, but reqwest is far more popular. Please double check that you are using the library you intended.

Also if we get access to the index, then we do not need the internet to find what version to add.

@epage
Copy link
Collaborator

epage commented May 11, 2022

Moved to rust-lang/cargo#10655

@epage epage closed this as completed May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants