
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
1.1 KiB
1.1 KiB
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
def report(manager, fileobj, sev_level, conf_level, lines=-1):
= bson.dumps(issues)
result with fileobj:
fileobj.write(result)
To register your plugin, you have two options:
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']}
If you're using pbr, add something like the following to your setup.cfg file:
[entry_points] bandit.formatters = bson = bandit_bson:formatter