Registry / devops / bandit-sarif-formatter

bandit-sarif-formatter

JSON →
library1.1.1pypypiunverified

A formatter that converts Bandit security analysis results into the SARIF Version 2.1.0 format, enabling integration with GitHub Advanced Security and other SARIF-compatible tools. The current version is 1.1.1. The package acts as a custom formatter for Bandit; release cadence is low, with maintenance updates as needed.

pip install bandit-sarif-formatter
INSTALL
IMPORT
SIG · BANDIT-SARIF-FORMA
B
bandit-sarif-formatter
devopspythonv1.1.1
Install
2.4s avg
Import
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.000s · 21MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

add_sarif_options
from bandit_sarif_formatter import add_sarif_options
from bandit_sarif_formatter import add_sarif_options

Example usage via command line or programmatic invocation. The preferred method is to use the bandit CLI with the custom formatter.

import bandit from bandit.core import manager, config # Use bandit with the sarif formatter via command line or programmatically # The quickest way: run bandit with the custom formatter # command: bandit -r /path/to/your/code -f sarif -o results.sarif # Or using Python: from bandit_sarif_formatter import add_sarif_options args = ['-r', '.', '-f', 'sarif', '-o', 'output.sarif'] bandit_runner = manager.BanditManager(config.BanditConfig(), agg_type='vuln') bandit_runner.run_tests(args)
Debug
Known issues
gotchaThe formatter produces a .sarif file; ensure Bandit itself is correctly installed and configured. The formatter only modifies output, not analysis.
fix
First install bandit, then run: bandit -r <target> -f sarif -o results.sarif
affects: >=1.0.0
gotchaThe package name on PyPI uses hyphens, but Python imports use underscores (bandit_sarif_formatter). Failing to replace hyphens with underscores causes ModuleNotFoundError.
fix
Use 'from bandit_sarif_formatter import ...' not 'bandit-sarif-formatter'.
affects: all
Upgrade
Version history
1.1.1latest on PyPI · released Oct 5, 2019
Audit
Dependencies
banditrequiredRequired runtime dependency; Bandit must be installed and used to generate the SARIF output.
sarif-omrequiredLibrary used for creating SARIF objects, automatically installed.
Agent activity
28 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
bandit-sarif-formatter — pip install bandit-sarif-formatter · libregistry