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

Refactor checking of hashes embedded in user-provided URLs #11923

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Apr 4, 2023

Some URLs can contain hashes, like so: https://example.com/archive-1.0.tar.gz#sha256=abcdef...
Such URLs can be provided by the user, in which case the hash must be considered good, and the dowloaded resource verified against that hash.
Such URLs can also be obtained from indexes, in which case the hash must be verified, but not trusted.

The hashes() method of InstallRequirements is extremely sensitive to whether original_link is set or not.
It is also very hard (to me) to understand when and why trust_internet must be True or False.
While working on #11897 I found that it was very easy to break hash checking just by trying to preserve req.original_link after obtaining a cache entry.

So I propose this refactoring that achieves the same behaviour in a more robust way, by extending hash_options with the hash passed in the link URL when we are certain that such a link is user provided.

Creating as draft to check tests pass and I'm still sane of mind... Not ready to review.

@sbidoul sbidoul force-pushed the refactor-link-hash-checking branch from 54a90b8 to 87a4991 Compare April 16, 2023 15:22
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.

1 participant