-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Wanted alive - Bandit config #14150
Comments
Try with this: {
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.banditEnabled": true,
"python.linting.banditArgs": [
"-r",
"--ini",
"${workspaceFolder}/.bandit"
],
} |
Same outcome, tests get linted. The final argument seems to take precedence over the config. > /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py bandit -r --ini ~/project/.bandit -f custom --msg-template {line},0,{severity},{test_id}:{msg} -n -1 ~/project/tests/test_project.py If the path to the > bandit -r --ini wrong/path/to/.bandit
[utils] WARNING Unable to parse config file wrong/path/to/.bandit or missing [bandit] section
[main] ERROR No targets found in CLI or ini files, exiting. |
@slmg Can you try running bandit using |
No bandit sadly does not pick up the > python -m bandit
[main] ERROR No targets found in CLI or ini files, exiting. Until > python -m bandit -r --ini .bandit
[main] INFO Using ini file for excluded paths
[main] INFO Using ini file for selected targets
... |
Closing this since this is a upstream issue. One thing you could try is set Bandit path ( {
"python.linting.banditArgs": [
"-r",
"--ini",
"${workspaceFolder}/.bandit"
],
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.banditEnabled": true,
"python.linting.banditPath": "<full path to bandit executable>"
} |
Environment data
1.49.1
2020.9.111407
Debian Buster
3.8.5
bandit 1.6.2
python.languageServer
setting: N/A[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (
python.languageServer: 'Microsoft'
), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]Expected behaviour
Configure
bandit
to lint main project's files but ignore tests from a directory structured as such:I would expect vscode to detect a
.bandit
file exists and automatically use it, as it is done for other linters (pylint
,mypy
,isort
, etc...).Actual behaviour
.bandit
config does not seem detected and parsed by this extension, even when explicitly passed via vscode's settings.This leads bandit to lint all files including the undesired tests folder (very noisy as it's full of
assert
statements).Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
Create the following
.bandit
config at the root of the project:To test bandit works, simply add
assert True
in bothproject.py
andtest_project.py
. Then run:Observe the config is ignored and warnings keep being reported for both
project.py
andtest_project.py
.Explicitly tell vscode to run bandit with its config:
See this does not change anything and
test_project.py
keeps being linted.Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)The text was updated successfully, but these errors were encountered: