publish: Use description
, license
and license_file
fields from embedded Cargo.toml
file
#7194
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes our handling of the
description
,license
andlicense_file
fields so that they are read from theCargo.toml
file embedded in the crate tarball, instead of the metadata JSON blob.This is another step forward towards avoiding issues like https://blog.vlt.sh/blog/the-massive-hole-in-the-npm-ecosystem in the Rust ecosystem. Note that, compared to e.g. npm, this is currently not exploitable due to the way cargo works, but it is still confusing to our users if the metadata does not match what is actually in the tarball.
This change required a small reordering of things in the publish endpoint. Specifically, the publish size limit is read from the database earlier than previously, which could potentially cause a race condition, but from what I can tell this race condition should not matter in practice (see commit message for details). Similarly, the tarball analysis step now happens before we run any
INSERT
queries on the database, since the tarball analysis result is now needed before we can insert anything. Thirdly, the description and license validation now happens after the tarball analysis for obvious reasons.