Skip to content

Commit cc36902

Browse files
committed
Fix --require-hashes trusting link hashes
When a direct URL with hash is provided as a dependency, --require-hash incorrectly considered the link hash as trusted.
1 parent 155f1aa commit cc36902

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pip/_internal/req/req_install.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,12 @@ def hashes(self, trust_internet: bool = True) -> Hashes:
287287
288288
"""
289289
good_hashes = self.hash_options.copy()
290-
link = self.link if trust_internet else self.original_link
290+
if trust_internet:
291+
link = self.link
292+
elif self.original_link and self.user_supplied:
293+
link = self.original_link
294+
else:
295+
link = None
291296
if link and link.hash:
292297
good_hashes.setdefault(link.hash_name, []).append(link.hash)
293298
return Hashes(good_hashes)

0 commit comments

Comments
 (0)