I'm using bandit to check my code for potential security issues:
bandit -r git-repository/
However, the most common item found by bandit is B101. It is triggered by assert statements within tests. I use pytest, so this is not a concern, but a good practice. I've now created a .bandit
file with
[bandit]
skips: B101
But that also skips a lot of other code. Is there a solution to this issue?
A possible solution is to tell
bandit
to skip tests altogether. Assuming your code lives in asrc
subfolder, runwith the following
bandit.yaml
in the project's root directoryThere is a bunch of related issues and pull requests.
Update: I like Diego's solution better.