flake8-bandit

4.1.1 · active · verified Tue Apr 14

flake8-bandit is a plugin for Flake8 that integrates the Bandit security linter directly into your Python code quality workflow. It automates security testing by scanning Python code for common security issues and vulnerabilities, reporting them as standard Flake8 errors. The current version is 4.1.1, released on August 29, 2022, with an irregular release cadence.

Warnings

Install

Quickstart

Install flake8-bandit and then simply run the `flake8` command on your Python project. flake8-bandit automatically registers itself and runs Bandit's security checks. You can configure specific Bandit tests using a `.bandit` configuration file in your project root.

# Install flake8-bandit (flake8 and bandit will be installed as dependencies)
pip install flake8-bandit

# Run flake8-bandit on your project (it integrates automatically with flake8)
# Example: Create a file named 'insecure_code.py'
# with content: 'import subprocess; subprocess.call("ls", shell=True)'
# Then run: flake8 insecure_code.py

# Expected output for the insecure_code.py example:
# insecure_code.py:1:22: S602 Use of subprocess.call with shell=True is insecure. Consider using subprocess.run with shell=False. (subprocess-run-with-shell-equals-true)

view raw JSON →