Skip to content

Commit 1e95c0c

Browse files
committed
ci: move Bandit config to pyproject.toml
1 parent 950f0b6 commit 1e95c0c

File tree

4 files changed

+11
-107
lines changed

4 files changed

+11
-107
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ repos:
3939
hooks:
4040
- id: bandit
4141
exclude: ^fuzz/generated/
42-
args: ["-c", "bandit.conf"]
42+
args: ["-c", "pyproject.toml"]
43+
additional_dependencies: [ "bandit[toml]" ]
4344

4445
- repo: https://github.com/jorisroovers/gitlint
4546
rev: v0.19.1

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,18 @@ specify a whole folder using ```./```
258258

259259
### Running bandit by itself
260260

261-
We have a configuration file for bandit called `bandit.conf` that you should use. This disables a few of the checkers.
261+
We have configuration section for Bandit in our `pyproject.toml`. This disables a few of the checkers.
262262

263263
To run it on all the code we scan, use the following:
264264

265265
```bash
266-
bandit -c bandit.conf -r cve_bin_tool/ test/
266+
bandit -c pyproject.toml -r cve_bin_tool/ test/
267267
```
268268

269269
You can also run it on individual files:
270270

271271
```bash
272-
bandit -c bandit.conf filename.py
272+
bandit -c pyproject.toml filename.py
273273
```
274274

275275
If you run it without the config file, it will run a few extra checkers, so you'll get additional warnings.

bandit.conf

Lines changed: 0 additions & 103 deletions
This file was deleted.

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ version = { attr = "cve_bin_tool.version.VERSION" }
115115
"sbom" = ["*.spdx", "*.json"]
116116
"mismatch" = ["*.py"]
117117

118+
[tool.bandit]
119+
skips = ["B603", "B607", "B404"]
120+
121+
[tool.bandit.assert_used]
122+
skips = ["*/test_*.py"]
123+
118124
[tool.coverage.run]
119125
source = ["cve_bin_tool", "test"]
120126
branch = true

0 commit comments

Comments
 (0)