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

Update content addressed github uri scheme #129

Merged
merged 2 commits into from
Dec 11, 2018

Conversation

njgheorghita
Copy link
Contributor

What was wrong?

Decision was made to sunset the fragment based hash verification for github uris and use their native blob system instead - Also mirrors what is suggested in the ERC 1319, so this will go towards having a cleaner standard amongst libraries.

How was it fixed?

Updated the utils and GithubOverHTTPS backend to use the blob scheme.

Cute Animal Picture

image

fixes #125

"Expected contents returned from Github to be base64 encoded, "
f"instead received {contents['encoding']}."
)
return base64.b64decode(contents["content"])
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I missed it but I expected to see somewhere that we verify that the contents match the hash. If that isn't present I think it needs to be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I chose to remove that for some reason that escapes me now, I'll set about re-implementing that.

if not all((path, scheme, authority)):
return False

if [term for term in expected_path_terms if term not in path]:
Copy link
Member

Choose a reason for hiding this comment

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

Generally the pattern for this is to use any

if any(term for term in expected_path_terms if not term in path):
    ...

The nice part about this is that it is lazy meaning it will exit on the first one that is truthy.

@njgheorghita njgheorghita force-pushed the http-uris branch 2 times, most recently from b287c43 to 7c911ed Compare December 10, 2018 10:25
@njgheorghita njgheorghita force-pushed the http-uris branch 10 times, most recently from 4ea7c34 to 7655cb4 Compare December 10, 2018 11:05
@njgheorghita
Copy link
Contributor Author

@pipermerriam ping - added a validation util to verify that the hash of the contents retrieved from a github blob uri match the hash in the uri

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

Badass and good investigative work on how the sha1 hash is calculated.

@njgheorghita njgheorghita merged commit ab67254 into ethpm:master Dec 11, 2018
@njgheorghita njgheorghita deleted the http-uris branch December 11, 2018 08:35
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.

Util for generating valid github uris
2 participants