Skip to content

Commit

Permalink
Bandit upgrade - allowing bandit to cope with more diverse outputs
Browse files Browse the repository at this point in the history
 - such as the sort of file paths you're more likely to get on ubuntu
 - and both High and Medium priority security warnings
 - really, should have done this some time ago
  • Loading branch information
ajCameron authored and javajawa committed Aug 20, 2023
1 parent ed572e0 commit 61e74ba
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/mewbot/tools/security_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ def get_positions_from_loc_line(loc_line: str) -> tuple[str, int, int]:
# Windows uses ':' in its file paths - thus some care needs to be taken to split the tokens
# down properly
loc_tokens = loc_line.split(":")

if len(loc_tokens) == 4:
problem_path = str(loc_tokens[-3])
problem_line = int(loc_tokens[-2])
problem_char_pos = int(loc_tokens[-1])

return problem_path, problem_line, problem_char_pos

# Four is the minimum, if : does not appear in the path
assert len(loc_tokens) > 4, f"{loc_tokens = } not as expected"

Expand All @@ -217,6 +225,10 @@ def severity_to_level(severity: str) -> str:
"""
if severity.lower() == "low":
return "notice"
if severity.lower() in ["medium", "med"]:
return "warning"
if severity.lower() == "high":
return "error"

raise NotImplementedError(f"severity {severity} not recognized!")

Expand Down

0 comments on commit 61e74ba

Please sign in to comment.