
The argparse module already has the capability to default to stdout at CLI parameter definition time. This patch utilizes this and avoids the opening of the output file by each formatter. Change-Id: Ib1e89492558fe1fc06966711b6014bd5b86b84c8
43 lines
1.1 KiB
ReStructuredText
43 lines
1.1 KiB
ReStructuredText
Bandit Report Formatters
|
|
========================
|
|
|
|
Bandit supports many different formatters to output various security issues in
|
|
python code. These formatters are created as plugins and new ones can be
|
|
created to extend the functionality offered by bandit today.
|
|
|
|
Example Formatter
|
|
-----------------
|
|
|
|
.. code-block:: python
|
|
|
|
def report(manager, fileobj, sev_level, conf_level, lines=-1):
|
|
result = bson.dumps(issues)
|
|
with fileobj:
|
|
fileobj.write(result)
|
|
|
|
To register your plugin, you have two options:
|
|
|
|
1. If you're using setuptools directly, add something like the following to
|
|
your `setup` call::
|
|
|
|
# If you have an imaginary bson formatter in the bandit_bson module
|
|
# and a function called `formatter`.
|
|
entry_points={'bandit.formatters': ['bson = bandit_bson:formatter']}
|
|
|
|
2. If you're using pbr, add something like the following to your `setup.cfg`
|
|
file::
|
|
|
|
[entry_points]
|
|
bandit.formatters =
|
|
bson = bandit_bson:formatter
|
|
|
|
|
|
Complete Formatter Listing
|
|
----------------------------
|
|
|
|
.. toctree::
|
|
:maxdepth: 1
|
|
:glob:
|
|
|
|
*
|