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

Invalid checking in hashlib plugin #865

Closed
ericwb opened this issue Mar 28, 2022 · 0 comments · Fixed by #914
Closed

Invalid checking in hashlib plugin #865

ericwb opened this issue Mar 28, 2022 · 0 comments · Fixed by #914
Labels
bug Something isn't working

Comments

@ericwb
Copy link
Member

ericwb commented Mar 28, 2022

Describe the bug

The hashlib_insecure_functions.py plugin is checkin for arguments that don't exist. For example, there is no kwarg for 'name'. The actual signature of the function is:

>>> inspect.signature(hashlib.new)
<Signature (name, data=b'', **kwargs)>

>>> inspect.signature(hashlib.md5)
<Signature (string=b'', *, usedforsecurity=True)>

The hashlib_new_insecure_functions example also includes a bunch of invalid examples.

Reproduction steps

See https://docs.python.org/3/library/hashlib.html

hashlib.new(name, [data, ]*, usedforsecurity=True)

Expected behavior

The checking should be accurate to the function API.

Bandit version

1.7.4 (Default)

Python version

3.9

Additional context

No response

@ericwb ericwb added the bug Something isn't working label Mar 28, 2022
ericwb added a commit that referenced this issue Jun 27, 2022
* hashlib does not support name as the kwargs argument 
* 'string' is not a keyword of kwargs

Fixes #865

Signed-off-by: Eric Brown <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant