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

Add more_info URL to screen formatter #360

Merged
merged 2 commits into from
Aug 9, 2018
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
9 changes: 7 additions & 2 deletions bandit/formatters/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
Screen formatter
================

This formatter outputs the issues as color coded text.
This formatter outputs the issues as color coded text to screen.
Copy link
Member

Choose a reason for hiding this comment

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

to the screen


:Example:

.. code-block:: none

>> Issue: [B301:blacklist_calls] Use of unsafe yaml load. Allows
>> Issue: [B506: yaml_load] Use of unsafe yaml load. Allows
Copy link
Member

Choose a reason for hiding this comment

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

Good catch

instantiation of arbitrary objects. Consider yaml.safe_load().

Severity: Medium Confidence: High
Location: examples/yaml_load.py:5
More Info: https://bandit.readthedocs.io/en/latest/
4 ystr = yaml.dump({'a' : 1, 'b' : 2, 'c' : 3})
5 y = yaml.load(ystr)
6 yaml.dump(y)
Expand All @@ -44,6 +45,7 @@
import sys

from bandit.core import constants
from bandit.core import docs_utils
from bandit.core import test_properties

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -100,6 +102,9 @@ def _output_issue_str(issue, indent, show_lineno=True, show_code=True,
issue.lineno if show_lineno else "",
COLOR['DEFAULT']))

bits.append("%s More Info: %s" % (
indent, docs_utils.get_url(issue.test_id)))

if show_code:
bits.extend([indent + l for l in
issue.get_code(lines, True).split('\n')])
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/formatters/test_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import bandit
from bandit.core import config
from bandit.core import docs_utils
from bandit.core import issue
from bandit.core import manager
from bandit.formatters import screen
Expand All @@ -46,7 +47,9 @@ def _template(_issue, _indent_val, _code, _color):
_issue.confidence.capitalize()),
"{} Location: {}:{}{}".
format(_indent_val, _issue.fname, _issue.lineno,
screen.COLOR['DEFAULT'])]
screen.COLOR['DEFAULT']),
"{} More Info: {}".format(
_indent_val, docs_utils.get_url(_issue.test_id))]
if _code:
return_val.append("{}{}".format(_indent_val, _code))
return '\n'.join(return_val)
Expand Down