Skip to content

Commit

Permalink
Fix --require-hashes trusting link hashes
Browse files Browse the repository at this point in the history
When a direct URL with hash is provided as a dependency, --require-hash
incorrectly considered the link hash as trusted.
  • Loading branch information
sbidoul committed Apr 8, 2023
1 parent 155f1aa commit d0cf1ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions news/11938.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When package A depends on package B provided as a direct URL dependency including a hash
embedded in the link, the --require-hashes option did not warn when user supplied hashes
were missing for package B.
7 changes: 6 additions & 1 deletion src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,12 @@ def hashes(self, trust_internet: bool = True) -> Hashes:
"""
good_hashes = self.hash_options.copy()
link = self.link if trust_internet else self.original_link
if trust_internet:
link = self.link
elif self.original_link and self.user_supplied:
link = self.original_link
else:
link = None
if link and link.hash:
good_hashes.setdefault(link.hash_name, []).append(link.hash)
return Hashes(good_hashes)
Expand Down

0 comments on commit d0cf1ad

Please sign in to comment.