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

Update crates.io index when necessary to avoid errors #340

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

mystor
Copy link
Collaborator

@mystor mystor commented Oct 14, 2022

If we would generate an error due to an audit-as-crates-io policy being specified for a crate which doesn't appear to be in the index, it may be because the local copy of the index is out-of-date.

With these changes, if we notice the index is out of date in this way, we'll update our local copy of the index and re-run our checks. This should avoid potential issues with new audits being added for audit-as-crates-io = true crates reporting errors on machines which have an out-of-date copy of the index.

In the future, we may want to switch to instead using the sparse http API for crates.io, rather than using crates-index, in order to handle running on machines using the new sparse crates.io registry support which may be stabilized soon (rust-lang/cargo#11224). Alternatively it may be worth asking cargo to add a new subcommand to check if a specific crate exists in the index, which could take advantage of whatever representation is currently being used as well as any caching cargo performs under the hood.

The bulk of this patch involves changing how the mock index is handled in tests to make it possible to test this updating behaviour.

src/main.rs Outdated Show resolved Hide resolved
If we would generate an error due to an audit-as-crates-io policy being
specified for a crate which doesn't appear to be in the index, it may be
because the local copy of the index is out-of-date.

With these changes, if we notice the index is out of date in this way,
we'll update our local copy of the index and re-run our checks.

This should avoid potential issues with new audits being added for
audit-as-crates-io = true crates reporting errors on machines which have
an out-of-date copy of the index.
@bholley bholley merged commit bb3f992 into mozilla:main Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants