Bandit Executor¶
Category: Source Code Analysis
Script: bandit.py
Integration: CLI
Faraday Plugin: BanditPlugin
Website: https://bandit.readthedocs.io/
Description¶
Runs Bandit static analysis (SAST) on a Python source code directory or Git repository and imports the findings into Faraday.
Prerequisites¶
banditinstalled and available in the agent'sPATHgit, if you scan a repository by URL- Read access to the Python source code, either as a local path or a Git repository
Configuration¶
Environment Variables (Setup)¶
| Variable | Required | Description |
|---|---|---|
GIT_USERNAME |
No | Username for cloning private repositories over HTTPS (default: oauth2) |
GIT_TOKEN |
No | Access token for cloning private repositories over HTTPS |
Execution Arguments¶
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
BANDIT_TARGET |
string | No | Path to a file or directory to scan. When BANDIT_GIT_URL is set, it is a subpath inside the cloned repository. |
BANDIT_CONFIDENCE |
string | No | Minimum confidence to report: LOW, MEDIUM or HIGH |
BANDIT_SEVERITY |
string | No | Minimum severity to report: LOW, MEDIUM or HIGH |
BANDIT_SKIP |
list | No | List of Bandit test IDs to skip (e.g., ["B101", "B301"]) |
BANDIT_GIT_URL |
url | No | Git repository to clone and scan |
BANDIT_GIT_REF |
string | No | Branch or tag to clone (default: the repository's default branch) |
YAML Configuration Example¶
executors:
bandit:
repo_executor: bandit.py
max_size: 65536
varenvs:
GIT_USERNAME: "<git_username>"
GIT_TOKEN: "<git_token>"
params:
BANDIT_TARGET:
mandatory: false
type: string
base: string
BANDIT_CONFIDENCE:
mandatory: false
type: string
base: string
BANDIT_SEVERITY:
mandatory: false
type: string
base: string
BANDIT_SKIP:
mandatory: false
type: list
base: list
BANDIT_GIT_URL:
mandatory: false
type: url
base: string
BANDIT_GIT_REF:
mandatory: false
type: string
base: string
How It Works¶
- If
BANDIT_GIT_URLis set, makes a shallow clone of the repository (atBANDIT_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates withGIT_USERNAME/GIT_TOKEN. - Runs
bandit -ron the target and requests XML output, applying the confidence, severity and skip options - Parses the XML with
BanditPluginand sends the results to Faraday - Deletes the temporary clone when the run ends
Notes¶
- You must set
BANDIT_TARGET,BANDIT_GIT_URL, or both. The run fails otherwise. BANDIT_TARGETmust point inside the cloned repository. Paths that escape it (e.g.,../) are rejected.- If Bandit finds nothing, the run finishes successfully with no results.
- The token is hidden in the agent log if the clone fails.
- Supports the shared agent parameters (
AGENT_CONFIG_*tags and severity filters).