Uncommitted Cargo.lock files prevent reproducing .crate files from source #9242
Labels
A-reproducibility
Area: reproducible / deterministic builds
S-triage
Status: This issue is waiting on initial triage.
(Apologies if I've filed this in the wrong place; happy to move it wherever it makes sense.)
There's been some interest lately in ensuring that code uploaded to crates.io is the same as the code in the repository on GitHub.
Aside on why this is worth doing
Most people who are interested in a crate's code will look at GitHub (or similar) repository, not the code uploaded to crates.io (citation needed, but I know I do this and I assume most others do too). This means that the code that's actually running is looked at by comparatively fewer people, and authors of malicious crates can make their vulnerabilities less likely to be discovered. This has happened in practice with the
event-stream
NPM package. By comparing the published crate to the GitHub source, this ensures that any malicious code must be visible when people go looking for it.This doesn't need to be done by cargo, of course, but Cargo's current method of generating crate files makes it difficult for any tool to do this.
Ideally, .crate files would be bit-for-bit reproducible. If that were the case, this would be as simple as downloading the
.crate
file, cloning the source, runningcargo package
, and comparing hashes. #8864 made it most of the way there, but it fails in practice (with at least the crates I tested, the latest versions ofhyper
andrand
), because the Cargo.lock files in the uploaded crate differ from the newly generated one. The crates follow the official guidance to omit the file (because they're libraries), so my Cargo generates a new one on the fly, including any new versions of dependencies since the crate was uploaded. Therefore, there's a mismatch.I see a few solutions here:
.crate
files for crates that only contain libraries. I assume this file is never actually read unless the crate in question was passed directly tocargo install
? If so, this seems like the best way forward.The text was updated successfully, but these errors were encountered: