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

Validate hash regardless of type #4534

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check hash regardless of type
  • Loading branch information
Adrian Wilkins committed Sep 21, 2021
commit d80d910f0d3d42c239934e661ad1203f1a0df7b9
23 changes: 13 additions & 10 deletions poetry/installation/executor.py
Original file line number Diff line number Diff line change
@@ -608,17 +608,20 @@ def _download_link(self, operation, link):
archive = self._chef.prepare(archive)

if package.files:
archive_hash = (
"sha256:"
+ FileDependency(
package.name,
Path(archive.path) if isinstance(archive, Link) else archive,
).hash()
dep = FileDependency(
package.name,
Path(archive.path) if isinstance(archive, Link) else archive,
)
if archive_hash not in {f["hash"] for f in package.files}:
raise RuntimeError(
"Invalid hash for {} using archive {}".format(package, archive.name)
)
for file in package.files:
hash_name, expected_digest = file["hash"].split(":")
hsh = dep.hash(hash_name)
if hsh != expected_digest:
print(hsh)
raise RuntimeError(
"Invalid {} hash for {} using file {}\n{}".format(
hash_name, package, link.filename, hsh
)
)

return archive