Bandit
Bandit is an open-source static analysis tool designed to find common security issues in Python code. It is open source under the Apache-2.0 license. It runs on Linux, macOS, and Windows.
Updated
- Pricing
- Open Source
- License
- Apache-2.0
- Platforms
- Linux, macOS, Windows
- Category
- Application Security Tools
What Is Bandit?
Bandit is an open-source static analysis tool designed to find common security issues in Python code. It analyzes the AST of Python files and flags issues like assert statements, hardcoded passwords, insecure shell execution, and weak cryptographic operations.
Use Cases
Automated Python security linting in pre-commit hooks and CI/CD pipelines.
Strengths and Limitations
Strengths
- +Maintained by PyCQA after starting within the OpenStack Security Project.
- +Builds an AST for each file and runs check plugins against its nodes.
- +Extensible with custom plugins and configurable severity levels.
Limitations
- -Focused on Python only; no cross-language support.
- -Detects known anti-patterns rather than complex data-flow vulnerabilities.
Defensive Use
Catching common Python security anti-patterns before code is committed or merged.
Bandit Alternatives
4 tools| Tool | License | Platforms | Pricing |
|---|---|---|---|
| CodeQL Semantic code analysis engine that compiles source code into queryable databases to discover vulnerabilities with QL queries. | MIT (queries); proprietary CLI | Linux, macOS, Windows | Free / Commercial |
| Semgrep Fast static analysis engine for codebases and CI/CD pipelines, matching semantic code patterns to find security vulnerabilities. | LGPL-2.1-only | Linux, macOS, Windows | Free / Commercial |
| Snyk Freemium application security platform that scans source code, open-source dependencies, containers, and IaC for vulnerabilities and license issues. | Proprietary (platform); Apache-2.0 (Snyk CLI) | Linux, macOS, Windows | Freemium |
| SonarQube Multi-language static analysis and code quality platform with open-source Community Build and commercial Server and Cloud editions. | LGPL-3.0-or-later (source); Sonar Source-Available License v1.0 (bundled analyzers) | Linux, macOS, Windows | Free / Commercial |
Frequently Asked Questions
What is Bandit?→
Bandit is an open-source static analysis tool designed to find common security issues in Python code. It analyzes the AST of Python files and flags issues like assert statements, hardcoded passwords, insecure shell execution, and weak cryptographic operations.
What is Bandit used for?→
Automated Python security linting in pre-commit hooks and CI/CD pipelines.
What are the strengths of Bandit?→
- +Maintained by PyCQA after starting within the OpenStack Security Project.
- +Builds an AST for each file and runs check plugins against its nodes.
- +Extensible with custom plugins and configurable severity levels.
What are the limitations of Bandit?→
- +Focused on Python only; no cross-language support.
- +Detects known anti-patterns rather than complex data-flow vulnerabilities.
How is Bandit used defensively?→
Catching common Python security anti-patterns before code is committed or merged.