-
-
Notifications
You must be signed in to change notification settings - Fork 621
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
Bandit 1.6.0 no longer respects excluded directories #488
Bandit 1.6.0 no longer respects excluded directories #488
Comments
Most likely a regression caused by #450 |
Thanks, I can try fix it in a couple hours |
I have also just run into this issue with 1.6.0 - my auto builds are now failing due to scanning excluded directories :) |
Likewise I have found that |
Yep, I just encountered this as well. Glad to see there's already an issue filed and a fix in the works. I'll temporarily downgrade to 1.5.1 until 1.6.1 is out. |
pinning to 1.5.1 worked out for me :) keep up the good work! |
* Due to a bug upstream bandit 1.6.0 doesn't honor the excluded directories, causing the failure of the bandit tox environments. See PyCQA/bandit#488 * Temproarily forcing bandit to be < 1.6.0 until the fix is available upstream. Change-Id: I8627d2a4e0e4b7f604b4dea843b910bbc5d4de45
Workaround for bug reported here: PyCQA/bandit#488 Signed-off-by: Ryan Beck-Buysse <rbuysse@bitwise.io>
Workaround for bug reported here: PyCQA/bandit#488 Signed-off-by: Ryan Beck-Buysse <rbuysse@bitwise.io>
Workaround for bug reported here: PyCQA/bandit#488 Signed-off-by: Ryan Beck-Buysse <rbuysse@bitwise.io>
I confirm this bug. |
Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: I110829ef960e3ee146f47871ef076491244bf4fa Signed-off-by: Dean Troyer <dtroyer@gmail.com>
* Update python-openstackclient from branch 'master' - Blacklist Bandit 1.6.0 due to directory exclusion bug Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: I110829ef960e3ee146f47871ef076491244bf4fa Signed-off-by: Dean Troyer <dtroyer@gmail.com>
Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: Id944054deedd545c34fc28ccf043dd72e5f31220
* Update neutron from branch 'master' - Blacklist bandit 1.6.0 due to directory exclusion bug Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: Id944054deedd545c34fc28ccf043dd72e5f31220
Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: Id29f06b68a95f53ad62bdc597bbb0f12bc4d6a60
* Update neutron-lib from branch 'master' - Blacklist bandit 1.6.0 due to directory exclusion bug Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: Id29f06b68a95f53ad62bdc597bbb0f12bc4d6a60
There's a regression[0] in bandit 1.6.0 which causes bandit to stop respecting excluded directories, and our tests throw a bunch of violations. Blacklist this version, but allow newer versions as there is already a pull request[1] to fix it, and I expect it will be included in the next release. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: Ie4dbfb3f54e4aac00e0537d5760b7a8fc81b35a2
* Update keystone from branch 'master' - Blacklist bandit 1.6.0 There's a regression[0] in bandit 1.6.0 which causes bandit to stop respecting excluded directories, and our tests throw a bunch of violations. Blacklist this version, but allow newer versions as there is already a pull request[1] to fix it, and I expect it will be included in the next release. [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 Change-Id: Ie4dbfb3f54e4aac00e0537d5760b7a8fc81b35a2
* Update networking-odl from branch 'master' - Blacklist bandit, bump neutron-lib and retire neutron-lbaas Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. (Original commit is based on Id944054deedd545c34fc28ccf043dd72e5f31220) neutron-lbaas is retired [2], so networking-odl dependencies must be removed. Trunk constants were moved to neutron-lib from neutron with [3] from 1.25.0, and were removed from neutron with [4], thus lower-constraints must point to at least 1.25.0. To pass the gate fix sphinx requirements for python>3.4 (Original Change-Id: I6e709385fefe12123ecab150237956297cc7e09f) [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 [2] http://lists.openstack.org/pipermail/openstack-discuss/2019-May/006158.html [3] https://review.opendev.org/636989 [4] https://review.opendev.org/649672 Change-Id: I698caa93a188f7be206c18d79152dd81eb4029d3
Workaround for bug reported here: PyCQA/bandit#488 Signed-off-by: Richard Berg <rberg@bitwise.io>
Can anyone confirm this bug has been fixed? I still run $ bandit --debug -r . -x $(pwd)/.tox
...
[node_visitor] DEBUG {'imports': {'sys', '_locale', 'locale'}, 'import_aliases': {}, 'node': <_ast.Load object at 0x7fc53651c278>, 'linerange': [0, 1], 'filename': './.tox/bandit/lib/python3.6/_bootlocale.py'} |
Interestingly, specifying an absolute target path combined with absolute exclusion paths seems to work: $ bandit -x $(pwd)/.tox/ -r $(pwd)
[main] INFO profile include tests: None
[main] INFO profile exclude tests: None
[main] INFO cli include tests: None
[main] INFO cli exclude tests: None
[main] INFO running on Python 3.6.8
Run started:2019-10-10 08:51:10.630871
Test results:
...
Code scanned:
Total lines of code: 70
Total lines skipped (#nosec): 0
Run metrics:
Total issues (by severity):
Undefined: 0.0
Low: 2.0
Medium: 0.0
High: 0.0
Total issues (by confidence):
Undefined: 0.0
Low: 0.0
Medium: 0.0
High: 2.0
Files skipped (0):
|
I am trying to use bandit 1.6.2 and excluded directories are not respected. This issue does not appear to be fixed. |
@LefterisJP I'm using bandit 1.6.2 and it works, however it depends on how you specify all paths. I'm using all full relative paths (eg. |
This issue still exists nearly one year later on Bandit 1.6.2. Unclear why it is closed. While it makes very little sense, E.g. if you have a
will work as intended whereas
Will attempt to scan all of The current arg is: parser.add_argument(
'-x', '--exclude', dest='excluded_paths', action='store',
default=','.join(constants.EXCLUDE),
help='comma-separated list of paths (glob patterns '
'supported) to exclude from scan '
'(note that these are in addition to the excluded '
'paths provided in the config file) (default: ' +
','.join(constants.EXCLUDE) + ')'
) Which gets passed to Line 457 in c6b1302
Independent of this issue, it might be sensible to add |
* Adapt bandit command parameters to make it work with the latest version of bandit allowing to relax the version constraint. * See also: PyCQA/bandit#488 Change-Id: Ide0f7c05de141c6131e9340e61f821189ed503a4
Still having this issue in 1.7.0, pinning to 1.5.1 doesn't help. For gitlab reasons I had to include the virtualenv inside the project_root and bandit ignores all attempts to ignore that folder... |
Just confirming that this issue still persists in 1.7 |
Coming back here include my workaround. Using absolute paths has worked, but since that wasn't an option for gitlab i found that
seems to respect the excluded folder. |
@ericwb please reopen based on ample evidence above. |
I've faced just the same issue on 1.7. This command is hanging for several minutes: bandit -lll -r -x tests . as well as this one: bandit -lll -r -x "tests/*" . but this one works just as expected:
|
The help output says that it excludes This is certainly not resolved and needs to be reopened. |
See PyCQA/bandit#488 as a depressing issue.
Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. (Original commit is based on Id944054deedd545c34fc28ccf043dd72e5f31220) neutron-lbaas is retired [2], so networking-odl dependencies must be removed. Trunk constants were moved to neutron-lib from neutron with [3] from 1.25.0, and were removed from neutron with [4], thus lower-constraints must point to at least 1.25.0. To pass the gate fix sphinx requirements for python>3.4 (Original Change-Id: I6e709385fefe12123ecab150237956297cc7e09f) Conflicts: .zuul.d/project.yaml doc/requirements.txt lower-constraints.txt networking_odl/tests/unit/journal/test_full_sync.py requirements.txt test-requirements.txt [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 [2] http://lists.openstack.org/pipermail/openstack-discuss/2019-May/006158.html [3] https://review.opendev.org/636989 [4] https://review.opendev.org/649672 Change-Id: I698caa93a188f7be206c18d79152dd81eb4029d3
Bandit 1.6.0 introduces a regression[0] with the -x option, a fix is expected to be included in 1.6.1 soon. (Original commit is based on Id944054deedd545c34fc28ccf043dd72e5f31220) neutron-lbaas is retired [2], so networking-odl dependencies must be removed. Trunk constants were moved to neutron-lib from neutron with [3] from 1.25.0, and were removed from neutron with [4], thus lower-constraints must point to at least 1.25.0. To pass the gate fix sphinx requirements for python>3.4 (Original Change-Id: I6e709385fefe12123ecab150237956297cc7e09f) Conflicts: .zuul.d/project.yaml .zuul.d/jobs.yaml doc/requirements.txt requirements.txt [0] PyCQA/bandit#488 [1] PyCQA/bandit#489 [2] http://lists.openstack.org/pipermail/openstack-discuss/2019-May/006158.html [3] https://review.opendev.org/636989 [4] https://review.opendev.org/649672 Change-Id: I698caa93a188f7be206c18d79152dd81eb4029d3
Can confirm here than it still doesn't work when I add exclude tests to [tool.bandit]
exclude = "./tests/*" |
Bandit 1.7.4 (Python 3.10.4) bandit -c pyproject.toml -r src with config [tool.bandit]
exclude_dirs = ["*/tests/*"] works as expected. All exluded dirs are then: ['*/tests/*', '.svn', 'CVS', '.bzr', '.hg', '.git/*', '__pycache__/*', '.tox', '.eggs', '*.egg'] |
@zelenyjan There are a few interesting facts about the information your share:
Can you share your complete Bandit (and Tox) configuration, please? Also, can you try to run against
Related: #528 And yes, the implementation of the config parsing is super-complicated and probably warrants a complete rewrite. 😟 |
I found
[tool.bandit]
exclude_dirs = ["*/tests/*"]
skips = ["B410", "B106", "B308", "B703", "B311", "B324", "B105", "B110"] # just for testing
[flake8]
ignore = E203, E501, W503, B950, FS003, S101
max-line-length = 120
per-file-ignores = __init__.py:F401,tests/*.py: S101
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv
pytest-mark-no-parentheses = true
pytest-fixture-no-parentheses = true for testing just created To exlude
[tool.bandit]
exclude_dirs = ["*/tests/*", "*/.tox/*", "*/.venv/*"] |
Bandit not respecting values provided in .bandit file because of a known issue PyCQA/bandit#488
Describe the bug
Prior to the bandit 1.6.0 release, I was using bandit like so:
However, with bandit 1.6.0 the
./mymodule1/tests/
and./mymodule2/tests/
directories are included in the results. I have confirmed that you can exclude individual files still, just not directories.To Reproduce
Steps to reproduce the behavior:
bandir -r . -x ./your-new-dir/
Expected behavior
Bandit should be excluding the directories entirely that are passed as args to the
-x
flag.Bandit version
The text was updated successfully, but these errors were encountered: