Skip to content

Check hash when downloading ports - #8788

Merged
quantum5 merged 6 commits into
emscripten-core:incomingfrom
quantum5:ports-hash
Jun 18, 2019
Merged

quantum5 merged 6 commits into
emscripten-core:incomingfrom
quantum5:ports-hash

Conversation

@quantum5

Copy link
Copy Markdown
Member

Fixes #8568.

@quantum5
quantum5 requested review from aheejin, kripken and tlively June 12, 2019 23:10

@kripken kripken left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

How does this change the update process for a port? Is there a convenient way to get the new hash, or will people need to do something on the commandline? We should document the best way to do it, perhaps as a comment on fetch_project.

@quantum5

Copy link
Copy Markdown
Member Author

The laziest way to update the port is to just build the port locally, and copy the new hash from the exception message.

The another way is to do curl -L URL | sha512sum. I am actually not sure which one is better.

@quantum5
quantum5 requested a review from kripken June 14, 2019 21:11
Comment thread tools/system_libs.py Resolved
Comment thread tools/system_libs.py Outdated
if sha512hash:
actual_hash = hashlib.sha512(data).hexdigest()
if actual_hash != sha512hash:
raise RuntimeError('Unexpected hash: ' + actual_hash)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we expect developers to update their hashes only after seeing this error, it might be a good idea to add some documentation of that to the error message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a suggestion to update the hash in the port file.

@quantum5
quantum5 requested a review from tlively June 18, 2019 00:30
@quantum5
quantum5 merged commit e293d8c into emscripten-core:incoming Jun 18, 2019
@quantum5
quantum5 deleted the ports-hash branch June 18, 2019 01:00
Comment thread tools/system_libs.py
actual_hash = hashlib.sha512(data).hexdigest()
if actual_hash != sha512hash:
raise RuntimeError('Unexpected hash: ' + actual_hash + '\n'
'If you are updating the port, please update the hash in the port module.')

@kripken kripken Jun 18, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how about putting the # To compute the sha512 hash, run curl URL | sha512sum comment in parentheses in this error message? otherwise I'm not sure people will see the source comment above, but they will definitely see this error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternatively we could just delete that comment since the error message already contains the new computed hash.

belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security problem] Downloads code archives without checking fingerprints

3 participants