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

Added checksum checking when downloading packages #100

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

victormlg
Copy link
Contributor

No description provided.

cf_remote/web.py Outdated
Comment on lines 28 to 31
def download_package(url, path=None, checksum=None):

if not checksum :
user_error("No checksum found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make checksum not an optional parameter.

cf_remote/web.py Outdated


if checksum and not SHA256_RE.match(checksum):
user_error("Invalid checksum or unsupOkported checksum algorithm: '%s'" % checksum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
user_error("Invalid checksum or unsupOkported checksum algorithm: '%s'" % checksum)
user_error("Invalid checksum or unsupported checksum algorithm: '%s'" % checksum)

cf_remote/web.py Outdated

answer = urllib.request.urlopen(url).read()

if checksum :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if checksum :
if checksum:

cf_remote/web.py Outdated
if checksum :
digest = hashlib.sha256(answer).digest().hex()
if checksum != digest :
user_error("Mismatching checksums")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
user_error("Mismatching checksums")
user_error("Downloaded file '{}' does not match expected checksum '{}'".format(filename, checksum)

Signed-off-by: Victor Moene <victor.moene@northern.tech>
@victormlg victormlg force-pushed the download-package-checksum branch from da1eaed to 2c726e3 Compare December 12, 2024 12:17
@olehermanse olehermanse merged commit 6fccfb4 into cfengine:master Dec 12, 2024
5 checks passed
@victormlg victormlg deleted the download-package-checksum branch December 12, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants