Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the line number when using HTML output format #683

Merged
merged 1 commit into from
Dec 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion bandit/formatters/html.py
Original file line number Diff line number Diff line change
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about also adding the column number? Thanks

Copy link
Contributor Author

@aludwin1 aludwin1 Dec 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! I'll attempt that change in another PR. Thanks for taking a look!

{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
Original file line number Diff line number Diff line change
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