From c5098797c225e1e1a2e4450994de0a8c56e1e9f3 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Sat, 13 Aug 2022 13:00:40 +1000 Subject: [PATCH 1/2] * bandit/cli/main.py: Set log level to ERROR if -q option is passed. --- bandit/cli/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bandit/cli/main.py b/bandit/cli/main.py index 47588859d..45a663de4 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -603,7 +603,7 @@ def main(): _init_logger(log_level=logging.DEBUG, log_format=log_format) if args.quiet: - _init_logger(log_level=logging.WARN) + _init_logger(log_level=logging.ERROR) try: profile = _get_profile(b_conf, args.profile, args.config_file) From c29890af908cdcc37fa85e981f0738f2e9d096aa Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Mon, 15 Aug 2022 12:16:00 +1000 Subject: [PATCH 2/2] Use 'count' action for --quiet option. Set log level to WARN with -q and ERROR with -q -q. --- bandit/cli/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bandit/cli/main.py b/bandit/cli/main.py index 45a663de4..542639181 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -322,7 +322,7 @@ def main(): "--quiet", "--silent", dest="quiet", - action="store_true", + action="count", help="only show output in the case of an error", ) parser.add_argument( @@ -602,8 +602,10 @@ def main(): log_format = b_conf.get_option("log_format") _init_logger(log_level=logging.DEBUG, log_format=log_format) - if args.quiet: + if args.quiet > 1: _init_logger(log_level=logging.ERROR) + elif args.quiet > 0: + _init_logger(log_level=logging.WARN) try: profile = _get_profile(b_conf, args.profile, args.config_file)