From 83fe26ad49f8dd80700301f8824419bd32200588 Mon Sep 17 00:00:00 2001 From: citizen204 Date: Mon, 6 Jul 2026 03:56:03 +0930 Subject: [PATCH 1/2] Honor quiet flag for early startup log messages Fixes #1250 --- bandit/cli/main.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bandit/cli/main.py b/bandit/cli/main.py index d7dba2efa..b20ff734f 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 """Bandit is a tool designed to find common security issues in Python code.""" + import argparse import fnmatch import logging @@ -134,12 +135,13 @@ def _log_info(args, profile): def main(): """Bandit CLI.""" # bring our logging stuff up as early as possible - debug = ( - logging.DEBUG - if "-d" in sys.argv or "--debug" in sys.argv - else logging.INFO - ) - _init_logger(debug) + if "-d" in sys.argv or "--debug" in sys.argv: + log_level = logging.DEBUG + elif "-q" in sys.argv or "--quiet" in sys.argv or "--silent" in sys.argv: + log_level = logging.WARN + else: + log_level = logging.INFO + _init_logger(log_level) extension_mgr = _init_extensions() baseline_formatters = [ @@ -393,8 +395,7 @@ def main(): blacklist_info.append(f"{b['id']}\t{b['name']}") plugin_list = "\n\t".join(sorted(set(plugin_info + blacklist_info))) - dedent_text = textwrap.dedent( - """ + dedent_text = textwrap.dedent(""" CUSTOM FORMATTING ----------------- @@ -421,8 +422,7 @@ def main(): The following tests were discovered and loaded: ----------------------------------------------- - """ - ) + """) parser.epilog = dedent_text + f"\t{plugin_list}" # setup work - parse arguments, and initialize BanditManager From 55fefef681231069e8189df56d6c2897f02c3b59 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Jul 2026 18:26:15 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- bandit/cli/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bandit/cli/main.py b/bandit/cli/main.py index b20ff734f..7fd29a525 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: Apache-2.0 """Bandit is a tool designed to find common security issues in Python code.""" - import argparse import fnmatch import logging @@ -395,7 +394,8 @@ def main(): blacklist_info.append(f"{b['id']}\t{b['name']}") plugin_list = "\n\t".join(sorted(set(plugin_info + blacklist_info))) - dedent_text = textwrap.dedent(""" + dedent_text = textwrap.dedent( + """ CUSTOM FORMATTING ----------------- @@ -422,7 +422,8 @@ def main(): The following tests were discovered and loaded: ----------------------------------------------- - """) + """ + ) parser.epilog = dedent_text + f"\t{plugin_list}" # setup work - parse arguments, and initialize BanditManager