Per-check skips in pyproject.toml causes test to be skipped across the whole project
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Start by tracing how Bandit reads [tool.bandit.assert_used] from pyproject.toml and applies its skips pattern during the bandit -c pyproject.toml -r click_async_plugins/ run. Add or locate a regression test using the reported tests/**.py pattern. Done means matching test files can use assert without findings while the assert in click_async_plugins/core.py is still reported.
Written by the indexing model from the issue text.
Description
Describe the bug
It seems not possible to use pyproject.toml to skip certain tests for certain files.
Reproduction steps
I added assert True to a file for testing:
% bandit -c pyproject.toml -r click_async_plugins/
[…]
Test results:
>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Severity: Low Confidence: High
CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
More Info: https://bandit.readthedocs.io/en/1.9.4/plugins/b101_assert_used.html
Location: click_async_plugins/core.py:15:4
14 def cli_core(ctx: click.Context) -> None:
15 assert True
16 ctx.obj = CliContext(itc=ITC())
[…]
Since I want to be able to use assert in all files tests/**/*.py, I added to pyproject.toml:
[tool.bandit.assert_used]
skips = 'tests/**.py'
Now running Bandit will no longer identify the assert in click-async-plugins/core.py, despite that file not matching the glob.
% bandit -c pyproject.toml -r click_async_plugins/
[…]
Test results:
No issues identified.
[…]
Expected behavior
I would expect this to work, obviously. Since it isn't, I was looking for documentation, but also could not find anything. And finally, not even --debug output provided an clues…
Bandit version
1.9.1 (Default)
Python version
3.14 (Default)
Additional context
% bandit --version
bandit 1.9.4
- Dominant language
- Python
- Stars
- 8.4k
- Forks
- 893
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyCQA/bandit
-
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Turn off progress bar in CIPossibly taken @silvatechf claimed this 28 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
`bandit -ii -ll -ii -ll` raises an `IndexError`Possibly taken @botbikamordehai2-sketch claimed this 181 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
intersystems/ipm#1338 ·
Maintainers usually reply within 1 day
-
separate_packages splits imports from the same explicitly configured packagePossibly taken @rahul05ranjan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOpenv1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day