-
Notifications
You must be signed in to change notification settings - Fork 94
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
cargo crev crate clean
not working
#434
Comments
After trying it out myself I immediately started getting similar problems. After some investigation I've changed the reported diagnostics and now it looks like this:
Any cleaning (even manually) does not seem to help, so I guess the reporter somehow got incorrect digests, which is not what I expected when writing the original code. Hi @LucianoBestia! |
Other than this |
I Will look into it. I use the function from crev lib to calculate the digest. |
@LucianoBestia Oh. In that case I can already tell you, that you probably want to use cargo-crev/cargo-crev/src/shared.rs Line 379 in ae2c6ff
For Rust we need to do bunch of sheningans before calculating digest. See comments. |
I have this code for the digest: fn ....
crate_name: &str,
crate_version_str: &str,
...
let crate_root = crate::cargo_registry_mod::cargo_registry_src_dir_for_crate(crate_name, crate_version_str)?;
let digest_clean = crev_lib::get_recursive_digest_for_dir(&crate_root, &cargo_min_ignore_list())?;
...
pub fn cargo_min_ignore_list() -> fnv::FnvHashSet<std::path::PathBuf> {
let mut ignore_list = std::collections::HashSet::default();
ignore_list.insert(std::path::PathBuf::from(".cargo-ok"));
ignore_list
}
/// cargo registry src directory for a crate
pub fn cargo_registry_src_dir_for_crate(crate_name: &str, crate_version: &str) -> anyhow::Result<std::path::PathBuf> {
let crate_dir_name = format!("{}-{}", crate_name, crate_version);
let crate_src_path = format!(
"{}/registry/src/github.ghproxy.top-1ecc6299db9ec823/{}",
home::cargo_home()?.to_str().unwrap(),
crate_dir_name
);
let crate_root = std::path::PathBuf::from_str(&crate_src_path)?;
// return
Ok(crate_root)
} |
Just for curiosity: Does crates.io have a digest or hash to verify if the downloaded files are not compromised? |
I see now in |
Last time I check it did not, at least not in the unpacked source. |
I found this "cksum" field in the json cargo registry files, not in the {
"name": "cargo_auto_lib",
"vers": "0.7.23",
"deps": [{
...
}
],
"cksum": "ba680d84f32d0dc2be953b5f7b3f2e6a3fd61fbe7d220b3ad18a6e7bd5d27daa",
"features": {},
"yanked": false,
"links": null
} |
I was also wondering why we are computing digests, instead of using the checksumming mechanism from the Cargo.lock files? |
Mostly because cargo is not obligated to stick with these. They are free to repackage all their |
If I run
cargo crev crate clean
and thencargo crev verify
, verify always says I have 2 unclean packages. I think they were two crates I was reviewing on an older version of crev, before I un-installed it and later re-installed it.This is with crev 0.21.4, installed from Cargo. I'm using Arch Linux on x86_64.
Running the clean command under strace shows that it's trying to delete some files that don't exist. It looks like the files in e.g.
~/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/anyhow-1.0.44/
are in a half-deleted state where some files remain (making verify say they're unclean) but clean doesn't know which ones still need deleting.I'll tar up the unclean folders as a backup, in case there's anything interesting in the presence / absence of files.
The text was updated successfully, but these errors were encountered: