Skip to content

Commit 180a7cf

Browse files
committed
Add regex to get error code from bandit output
This fix modifies the regex to search for the bandit error code. The bandit error code always begins with 'B' followed by a 3 digit number. This will effectively make Sublimelinter-bandit consistent with other plugins like Sublimelinter-pylint that show an error code. For example, pylint plugin shows as: 1:1 warning pylint: C0111 Missing module docstring (missing-docstring) Whereas the bandit plugin currently shows as: 21:1 warning bandit: Medium Use of insecure MD2, MD4, or MD5 hash function. After this fix is merged, it will display as: 21:1 warning bandit: B303 Use of insecure MD2, MD4, or MD5 hash function. Signed-off-by: Eric Brown <[email protected]>
1 parent 9fcfd7e commit 180a7cf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

linter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Bandit(PythonLinter):
2323
version_re = r'^bandit\s(?P<version>\d+.\d+.\d+)'
2424
version_requirement = '>= 1.3.0'
2525
regex = (
26-
r'^>>\sIssue:\s\[.+\]\s(?P<message>.+)$\r?\n'
26+
r'^>>\sIssue:\s\[(?P<code>[B]\d+):.+\]\s(?P<message>.+)$\r?\n'
2727
r'^.*Severity:\s(?:(?P<error>High)|(?P<warning>(Medium|Low))).*$\r?\n'
2828
r'^.*Location:.*:(?P<line>\d+)$\r?\n'
2929
)

0 commit comments

Comments
 (0)