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

crate source verification #110

Open
matthiaskrgr opened this issue Dec 15, 2021 · 4 comments
Open

crate source verification #110

matthiaskrgr opened this issue Dec 15, 2021 · 4 comments
Assignees
Labels

Comments

@matthiaskrgr
Copy link
Owner

matthiaskrgr commented Dec 15, 2021

It would be interesting if cargo-cache could find local extracted sources that differ from the contents of the respective .xz /.crate archives.

EDIT: idea dump:

  • git fsck all git repos (already implemented: --fsck) todo: parallelize
  • check extracted sources for mismatching sizes (already implemented)
  • read all the .crate archives and make sure they are ok (not sure if this is needed since cargo would complain anyway I guess..?)
  • check git repo checkouts for added/missing/edited files
  • check extracted crate sources content (probably expensive, need extract every .crate into a temp dir and compare hash sums / diffs of files, there might also be a ton of unexpected problems)
@matthiaskrgr
Copy link
Owner Author

might get away with checking if any files contained inside the extracted sources are newer than downloaded source archive (.crate)

@matthiaskrgr matthiaskrgr changed the title crate source cerification crate source verification Dec 17, 2021
@matthiaskrgr
Copy link
Owner Author

compare in-zip file against local source cache

https://rust-lang-nursery.github.io/rust-cookbook/compression/tar.html

use flate2::read::GzDecoder;
use std::fs::File;
use tar::Archive;

fn main() -> Result<(), std::io::Error> {
    let path = "datetime-0.5.2.crate";

    let tar_gz = File::open(path)?;
    let tar = GzDecoder::new(tar_gz);
    let mut archive = Archive::new(tar);

    let files = archive.entries()?;

    files.into_iter().for_each(|f| {
        let file = f.unwrap();
        // println!("{}", file.path().unwrap().display());
        // println!("{:?}", file.header());
        // print the file name and the size
        println!("{}, {} bytes", file.path().unwrap().display(), file.size());
    });

    Ok(())
}

@matthiaskrgr
Copy link
Owner Author

For the git source, we can go into checkouts, for instance: ~/.cargo/git/checkouts/druid-f6980810fb848923/c42de0b
and check with git-status / git diff

@matthiaskrgr matthiaskrgr self-assigned this Dec 20, 2021
@matthiaskrgr
Copy link
Owner Author

still missing: git checkout verification, check something like
git status --porcelain also handle what happens if we have checkout but no repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant