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 missing digest support to recipes #2351

Merged
merged 1 commit into from
Nov 14, 2020
Merged

Conversation

fuzzyTew
Copy link
Contributor

@fuzzyTew fuzzyTew commented Nov 9, 2020

This adds support for all the hash fragment types pypi may use: https://pip.pypa.io/en/stable/reference/pip_install/#hashes-from-pypi .

Allowing cryptographically secure hashes can help system administrators defend against compromise.

Documentation is only added for sha512sum and blake2bsum to maintain backwards compatibility in the interface and stay somewhat concise. These two algorithms are rated highly.

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

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

Very nice!
Looking good to me, thanks 🙏
Couple of notes for a potential follow up PR.

@AndreMiras AndreMiras merged commit f7fbc38 into kivy:develop Nov 14, 2020
@fuzzyTew
Copy link
Contributor Author

Thanks so much.

Additional note: It turns out pypi is recommending sha256, and also providing md5 and blake2-256. Should probably change the 3 algorithm choices here to match those.

expected_md5 = self.md5sum
expected_digests = {}
for alg in set(hashlib.algorithms_guaranteed) | set(('md5', 'sha512', 'blake2b')):
expected_digest = getattr(self, alg + 'sum') if hasattr(self, alg + 'sum') else None
Copy link
Contributor

Choose a reason for hiding this comment

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

@fuzzyTew fyi you could shorten

getattr(self, alg + 'sum') if hasattr(self, alg + 'sum') else None

to

getattr(self, alg + 'sum', None)

Copy link
Contributor

@xloem xloem Dec 3, 2020

Choose a reason for hiding this comment

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

Thanks, I didn't see that. If you have any interest / effort, I may have trouble getting to this for a while.

The biggest issue with my code is that I provided no way to set the digest length, so you can't do 256-bit blake2 which pypi uses.

Might be reasonable also to add a note regarding other security norms of the system not yet being as tight as the new algorithms.

EDIT: btw I am fuzzytew

xloem added a commit to xloem/python-for-android that referenced this pull request Dec 24, 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.

4 participants