Python security linter (SAST) · find common vulns in your code · CI-friendly · verified against Bandit 1.9.x (2026)

Bandit cheat sheet

Bandit (PyCQA) is a static security analyzer for Python. It parses your code into an AST and runs plugins that flag common weaknesses — eval/exec, shell=True, hardcoded passwords, weak crypto (md5), unsafe pickle/yaml.load, SQL built by string concat, requests with TLS verification off, and more. Each finding carries a test id (B###), a severity, and a confidence. Runs from the CLI, pre-commit, or CI, and emits JSON/SARIF for code scanning. Targets Bandit 1.9.x, Python 3.10+.

install & run understanding results configuration suppression & CI limits & ecosystem gotcha most common

Verified 2026-08-31 against the official docs at bandit.readthedocs.io & the PyCQA/bandit repo (Bandit 1.9.4, released 2026-02-26; Python 3.10–3.14). Findings are advisory — Bandit catches common patterns, not all vulnerabilities; expect false positives and triage them.

Outline

Point bandit -r at your source, read the severity/confidence + B### ids, then configure what to scan, suppress false positives, baseline legacy code, and wire it into CI.

Install & run

  1. 1Install & first scan
  2. 2Running bandit

Understanding results

  1. 3Severity & confidence
  2. 4Common checks (B###)
  3. 5Output formats

Configuration

  1. 6Select & skip tests
  2. 7Config file

Suppression & CI

  1. 8# nosec suppression
  2. 9Baseline
  3. 10CI & pre-commit

Limits & ecosystem

  1. 11What Bandit misses
  2. 12Ecosystem

Install & Run

Install, point it at your code, and get findings in seconds.

1Install & first scanpip / extras
2Running banditthe useful flags

Understanding Results

Read severity × confidence, learn the common B### ids, and pick an output format.

3Severity & confidencetriage
4Common checks (B###)what it flags
5Output formats-f / -o

Configuration

Choose which tests run and store the settings in your project config.

6Select & skip tests-t / -s
7Config filepyproject.toml

Suppression & CI

Silence verified false positives, baseline legacy code, and gate every PR.

8# nosec suppressioninline waivers
9Baselineonly new issues
10CI & pre-commitautomate it

Limits & Ecosystem

Know what Bandit can't see, and the tools that complement it.

11What Bandit missesscope
12Ecosystemthe toolbox

Worth memorizing

bandit -r ./srcrecursive scan — the core command
-x tests,.venvexclude paths
-ll / -iimin severity / confidence — cut noise
severity × confidencetriage high×high first
B602/B605shell=True / os.system (injection)
B301/B307/B506pickle / eval / yaml.load
B105 / B303 / B501secrets / md5 / verify=False
-f sarif / json / htmloutput formats (-o file)
-s / -tskip / run-only test ids
# nosec B605scoped waiver — comment why
-b baseline.jsonfail only on NEW issues
scans your code, not depsadd pip-audit / Safety