Skip to content

Commit

Permalink
This commit is to include the line number of a given occurrence when …
Browse files Browse the repository at this point in the history
…using HTML output format. (#683)

Resolves: #672
  • Loading branch information
aludwin1 committed Dec 27, 2020
1 parent 1956d64 commit 8eee173
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bandit/formatters/html.py
Expand Up @@ -263,6 +263,7 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1):
<b>Severity: </b>{severity}<br>
<b>Confidence: </b>{confidence}<br>
<b>File: </b><a href="{path}" target="_blank">{path}</a> <br>
<b>Line number: </b>{line_number}<br>
<b>More info: </b><a href="{url}" target="_blank">{url}</a><br>
{code}
{candidates}
Expand Down Expand Up @@ -358,7 +359,8 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1):
confidence=issue.confidence,
path=issue.fname, code=code,
candidates=candidates,
url=url)
url=url,
line_number=issue.lineno)

# build the metrics string to insert in the report
metrics_summary = metrics_block.format(
Expand Down
1 change: 1 addition & 0 deletions tests/unit/formatters/test_html.py
Expand Up @@ -120,6 +120,7 @@ def test_report_contents(self, get_issue_list, get_code):
self.assertIn('BBBBBBB', issue1.text)
self.assertIn('CCCCCCC', issue1.text)
self.assertIn('abc.py', issue1.text)
self.assertIn('Line number: 1', issue1.text)

@mock.patch('bandit.core.issue.Issue.get_code')
@mock.patch('bandit.core.manager.BanditManager.get_issue_list')
Expand Down

0 comments on commit 8eee173

Please sign in to comment.