executablebooks / sphinx-design

A sphinx extension for designing beautiful, screen-size responsive web components.
https://sphinx-design.readthedocs.io/en/furo-theme/
MIT License
187 stars 57 forks source link

🔧 Add FIPS compliant flag to md5 call #162

Closed gabor-varga closed 2 months ago

gabor-varga commented 10 months ago

Closes #161

welcome[bot] commented 10 months ago

Thanks for submitting your first pull request! You are awesome! :hugs:
If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.
Welcome to the EBP community! :tada:

chrisjsewell commented 10 months ago

Heya, usedforsecurity was only added in Python 3.9 https://docs.python.org/3/library/hashlib.html#hash-algorithms, so some handling for <3.9 needs to be implemented 😄

gabor-varga commented 10 months ago

Heya, usedforsecurity was only added in Python 3.9 https://docs.python.org/3/library/hashlib.html#hash-algorithms, so some handling for <3.9 needs to be implemented 😄

Ah indeed, and I thought it was just a nice one-line PR :)

chrisjsewell commented 10 months ago

Ah indeed, and I thought it was just a nice one-line PR

They never are 😂

gabor-varga commented 10 months ago

Ah indeed, and I thought it was just a nice one-line PR

They never are 😂

So I am not too proficient with python, maybe you can recommend the best solution for this. This seems to be straightforward:

has_usedforsecurity_support = float(sys.version[:3]) >= 3.9

Or something with the inspect module to check if md5 function supports the usedforsecurity kwargs, although that seems convoluted.

And then just use something like:

md5_kwargs = {"usedforsecurity": False} if has_usedforsecurity_support  else {}
hash = hashlib.md5(content.encode("utf8"), **md5_kwargs ).hexdigest()
codecov[bot] commented 10 months ago

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
sphinx_design/extension.py 100.00%

:loudspeaker: Thoughts on this report? Let us know!.

gabor-varga commented 10 months ago

@chrisjsewell do you think this is sufficient? I'll use my fork until the next release.

chrisjsewell commented 10 months ago

@chrisjsewell do you think this is sufficient? I'll use my fork until the next release.

Yep I think it's fine but bare with me to merge

codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.01%. Comparing base (074f21f) to head (4651d30).

:exclamation: Current head 4651d30 differs from pull request most recent head f66fd84

Please upload reports for the commit f66fd84 to get more accurate results.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #162 +/- ## ========================================== + Coverage 89.18% 90.01% +0.82% ========================================== Files 11 11 Lines 962 951 -11 ========================================== - Hits 858 856 -2 + Misses 104 95 -9 ``` | [Flag](https://app.codecov.io/gh/executablebooks/sphinx-design/pull/162/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | | |---|---|---| | [pytests](https://app.codecov.io/gh/executablebooks/sphinx-design/pull/162/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | `90.01% <100.00%> (+0.82%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

welcome[bot] commented 2 months ago

Congrats on your first merged pull request in this project! :tada: congrats
Thank you for contributing, we are very proud of you! :heart: