tools: Enable color for bandit.
- Also timeout can now be specified in tools.toml. - Not truncating the timestamp from bandit anymore, so dropping its golden file.
This commit is contained in:
parent
d1867f61ab
commit
195165d826
6 changed files with 19 additions and 36 deletions
|
|
@ -183,10 +183,14 @@ class TermStr(collections.UserString):
|
|||
is_italic = True
|
||||
elif code in ["04", "4"]: # underline
|
||||
is_underlined = True
|
||||
elif len(code) == 2 and code.startswith("3"): # 8 fg color
|
||||
elif len(code) == 2 and code.startswith("3"): # dim fg color
|
||||
fg_color = int(code[1])
|
||||
elif len(code) == 2 and code.startswith("4"): # 8 bg color
|
||||
elif len(code) == 2 and code.startswith("4"): # dim bg color
|
||||
bg_color = int(code[1])
|
||||
elif len(code) == 2 and code.startswith("9"): # high fg color
|
||||
fg_color = int(code[1]) + 8
|
||||
elif len(code) == 3 and code.startswith("10"): # high bg color
|
||||
bg_color = int(code[2]) + 8
|
||||
elif code == "5" and previous_code == "38": # simple fg color
|
||||
fg_color = int(codes[index+1])
|
||||
codes[index+1:index+2] = []
|
||||
|
|
|
|||
|
|
@ -382,16 +382,6 @@ def python_mccabe(path):
|
|||
# Status.not_applicable)
|
||||
|
||||
|
||||
@deps(deps={"pip/bandit"}, url="https://pypi.org/project/bandit/")
|
||||
def bandit(path):
|
||||
stdout, stderr, returncode = _do_command(
|
||||
[PYTHON_EXECUTABLE, "-m", "bandit.cli.main", "-f", "txt", path],
|
||||
timeout=TIMEOUT)
|
||||
status = Status.ok if returncode == 0 else Status.problem
|
||||
text_without_timestamp = "".join(stdout.splitlines(keepends=True)[2:])
|
||||
return status, text_without_timestamp
|
||||
|
||||
|
||||
@deps(deps={"perl-doc"}, url="http://perldoc.perl.org/",
|
||||
executables={"perldoc"})
|
||||
def perldoc(path):
|
||||
|
|
@ -472,7 +462,7 @@ def godoc(path):
|
|||
|
||||
|
||||
def make_tool_function(dependencies, command, url=None, success_status=None,
|
||||
error_status=None, has_color=False):
|
||||
error_status=None, has_color=False, timeout=None):
|
||||
if url is None:
|
||||
url = dependencies[0]
|
||||
command = command.split()
|
||||
|
|
@ -482,7 +472,7 @@ def make_tool_function(dependencies, command, url=None, success_status=None,
|
|||
@deps(deps=set(dependencies), url=url, executables=executables)
|
||||
def func(path):
|
||||
return _run_command(command + [path], success_status, error_status,
|
||||
has_color)
|
||||
has_color, timeout)
|
||||
return func
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,13 @@ tools_for_extensions = [
|
|||
command = "python3.7 -m modulefinder"
|
||||
success_status = "normal"
|
||||
|
||||
[bandit]
|
||||
dependencies = ["pip/bandit"]
|
||||
url = "https://pypi.org/project/bandit/"
|
||||
command = "python3.7 -m bandit.cli.main -f screen"
|
||||
has_color = true
|
||||
timeout = 60
|
||||
|
||||
[perl_syntax]
|
||||
dependencies = ["perl"]
|
||||
url = "https://en.wikipedia.org/wiki/Perl"
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
Test results:
|
||||
No issues identified.
|
||||
|
||||
Code scanned:
|
||||
Total lines of code: 2
|
||||
Total lines skipped (#nosec): 0
|
||||
|
||||
Run metrics:
|
||||
Total issues (by severity):
|
||||
Undefined: 0.0
|
||||
Low: 0.0
|
||||
Medium: 0.0
|
||||
High: 0.0
|
||||
Total issues (by confidence):
|
||||
Undefined: 0.0
|
||||
Low: 0.0
|
||||
Medium: 0.0
|
||||
High: 0.0
|
||||
Files skipped (0):
|
||||
|
|
@ -155,6 +155,10 @@ class TermStrTests(unittest.TestCase):
|
|||
termstr.TermStr("foo").bold())
|
||||
self.assertEqual(TermStr.from_term(eris.terminal.ESC + "[Kfoo"),
|
||||
termstr.TermStr("foo"))
|
||||
self.assertEqual(TermStr.from_term(eris.terminal.ESC + "[95mfoo"),
|
||||
termstr.TermStr("foo").fg_color(13))
|
||||
self.assertEqual(TermStr.from_term(eris.terminal.ESC + "[105mfoo"),
|
||||
termstr.TermStr("foo").bg_color(13))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -127,9 +127,6 @@ class ToolsTestCase(unittest.TestCase):
|
|||
def test_python_mccable(self):
|
||||
self._test_tool(tools.python_mccabe, self.HI_OK)
|
||||
|
||||
def test_bandit(self):
|
||||
self._test_tool(tools.bandit, self.HI_OK)
|
||||
|
||||
# FIX: Make the golden-file deterministic
|
||||
# def test_pydisasm(self):
|
||||
# self._test_tool(tools.pydisasm,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue