Output examples in the CSV, JSON and YAML formatter docs are out of date

Open Beginner friendly
#1,485 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
documentation

Research direction

Read the module docstrings in bandit/formatters/csv.py, bandit/formatters/json.py and bandit/formatters/yaml.py. Run each formatter on examples/yaml_load.py and compare its output with the examples shown on the formatter docs pages. Update the examples to match current output, including the fields and finding names described in the issue.

Written by the indexing model from the issue text.

Description

Describe the bug

The output examples in the module docstrings of bandit/formatters/csv.py, json.py and yaml.py (shown on the "Report formatters" docs pages) don't match what Bandit prints today:

  • CSV: the header doesn't have col_offset and end_col_offset, but the formatter writes them.
  • JSON and YAML: the results don't have col_offset and end_col_offset, and the metrics don't have skipped_tests. The YAML example also doesn't have issue_cwe.
  • CSV and JSON show the yaml.load finding as blacklist_calls / B301. The real output is yaml_load / B506.
Reproduction steps
  1. From a checkout of the repo, run:
    bandit -f csv examples/yaml_load.py
    bandit -f json examples/yaml_load.py
    bandit -f yaml examples/yaml_load.py
  2. Compare the output with the examples on the CSV, JSON and YAML formatter docs pages.
Expected behavior

The examples in the docs match the current output of each formatter.

Bandit version

1.9.5.dev23 (main)

Python version

3.14

Additional context

PRs are limited to collaborators, so I regenerated the three examples from the real output of examples/yaml_load.py on a branch on my fork (docstrings only):
https://github.com/PyCQA/bandit/compare/main...Dio77799:bandit:docs/formatter-examples

The XML example has the same blacklist_calls / B301 problem. I didn't touch it here because my branch for #1304 changes that same docstring.

Dominant language
Python
Stars
8.4k
Forks
893
Avg merge
6h 52m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PyCQA/bandit

All issues in PyCQA/bandit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.