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

B322 input listed as high severity, high confidence... when running python3 #402

Closed
geokala opened this issue Oct 11, 2018 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@geokala
Copy link

geokala commented Oct 11, 2018

Describe the bug
When running bandit under python 3, B322 'The input method in Python 2...' is listed as a high severity issue with high confidence.

At best, this should be lower confidence, but ideally it shouldn't complain on python 3 as (as it asserts itself) it's safe in python 3.

To Reproduce
Steps to reproduce the behavior:
While running in a python 3 virtualenv:
echo "test = input('Say something')" > test.py
bandit test.py

Expected behavior
No complaint about input is issued because this does not apply in python 3.

Bandit version

bandit 1.5.1
  python version = 3.4.3 (default, Nov 28 2017, 16:41:13) [GCC 4.8.4]

Additional context
N/A

@ericwb
Copy link
Member

ericwb commented Oct 12, 2018

This has come up before. I think I was the one who talked about it in IRC. So the tricky bit is that Bandit doesn't know what version of Python is being used to run the code its inspecting. I guess one workaround might be using the classifier defined in setup.py for the project and that may help some scenarios. But when discussed, the opinion was that the warning reported should advise the user that it only applies to code running in a Python2 environment. So we could improve the documentation also.

@pzelnip
Copy link

pzelnip commented Nov 2, 2018

So is the workaround to just disable B322 when your project is Python 3?

Could a possible fix be to allow one to specify the version of Python your project targets as a switch to bandit? Ie bandit -r --python3 /path/to/my/code?

@geokala
Copy link
Author

geokala commented Nov 3, 2018

@ericwb Does @pzelnip's suggestion sound reasonable, or at least to be the basis of something useful (e.g. some sort of mark/tag system similar to pytest- though that may be overkill for this)?

@ericwb ericwb added the bug Something isn't working label May 9, 2019
@ericwb ericwb added this to the Near Future milestone May 9, 2019
@ML-Chen
Copy link

ML-Chen commented Jan 14, 2021

This was resolved for me when I updated from Bandit 1.6 (from conda-forge) to 1.7 (from Pip). Yeah, this bug is a duplicate of #596, which was resolved by #662 which was merged into 1.7.0.

@ericwb ericwb removed this from the Near Future milestone Mar 29, 2022
@ericwb
Copy link
Member

ericwb commented Mar 29, 2022

The blacklist check for input() was removed with PR #662

@ericwb ericwb closed this as completed Mar 29, 2022
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

No branches or pull requests

4 participants