Skip to content

Conversation

Release-Candidate
Copy link

The current version of bandit (1.7.9) has additional output between Severity and Location and looks like this:

Test results:
>> Issue: [B404:blacklist] Consider possible security implications associated with the subprocess module.
   Severity: Low   Confidence: High
   CWE: CWE-78 (https://cwe.mitre.org/data/definitions/78.html)
   More Info: https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess
   Location: <stdin>:14:0
14	import subprocess  # 1nosec B404

--------------------------------------------------

The updated regex works with this kind of output too.

@Kristinita
Copy link

Kristinita commented Mar 23, 2025

Status: FIXED ✔️

1. Working plugin

The solution of @Release-Candidate doesn’t work for me. Modified linter.py:

from SublimeLinter.lint import PythonLinter, util


class Bandit(PythonLinter):
    cmd = ("bandit", "${args}", "--silent", "${file}")
    defaults = {
        "selector": "source.python"
    }
    multiline = True
    regex = (
        r"^>>\s+Issue:\s+\[(?P<code>[B]\d+):.*?\]\s+(?P<message>.*)$\r?\n"
        r".*?Severity:\s+(?:(?P<error>High)|(?P<warning>Medium|Low)).*\r?\n"
        r"(.*\r?\n)*?"
        r"^.*?Location:\s+.*?:(?P<line>\d+)(?::\d+)?\s*$\r?\n"
    )

This plugin successfully works for me on my environment.

2. Environment

  1. Microsoft Windows 11 [Version 10.0.22621.3085]
  2. Sublime Text 4 Build 4192
  3. SublimeLinter v4.26.0
  4. Python 3.13.2
  5. Bandit 1.8.3

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants