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

Hashlib linter should not warn when usedforsecurity=False is set #39

Closed
djmattyg007 opened this issue May 7, 2022 · 3 comments · Fixed by #42
Closed

Hashlib linter should not warn when usedforsecurity=False is set #39

djmattyg007 opened this issue May 7, 2022 · 3 comments · Fixed by #42

Comments

@djmattyg007
Copy link
Contributor

This is a built-in flag that affirms the code is not using md5 for security-related purposes. In my code's case, I'm manually calculating a checksum as required by the AWS S3 API.

@mschwager
Copy link
Contributor

Hi there,

Good catch! Would you be interested in submitting a PR to fix this?

The hashlib linter lives in bad_hashlib_use.py. This could be fixed by switching BadHashlibUseLinter to inherit from BadKwargUseLinter instead of BadModuleAttributeUseLinter. From there, you could create a missing_or_true predicate to only catch instances of the function call where the usedforsecurity kwarg is missing (defaults to True), or explicitly set to True. Similar to bad_onelogin_kwarg_use.py.

Fortunately this solution is backwards compatible with pre-3.9 versions of Python since we're still flagging the usedforsecurity missing case 👍

@djmattyg007
Copy link
Contributor Author

Good catch! Would you be interested in submitting a PR to fix this?

I'm working on a PR now :)

@djmattyg007
Copy link
Contributor Author

@mschwager I just submitted #42

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 a pull request may close this issue.

2 participants