-
Notifications
You must be signed in to change notification settings - Fork 18
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
Added checksum checking when downloading packages #100
Conversation
cf_remote/web.py
Outdated
def download_package(url, path=None, checksum=None): | ||
|
||
if not checksum : | ||
user_error("No checksum found") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if checksum : | |
if checksum: |
cf_remote/web.py
Outdated
if checksum : | ||
digest = hashlib.sha256(answer).digest().hex() | ||
if checksum != digest : | ||
user_error("Mismatching checksums") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
da1eaed
to
2c726e3
Compare
No description provided.