Honor quiet flag for early startup log messages#1452
Open
citizen204 wants to merge 2 commits into
Open
Conversation
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
-q/--quiet/--silent, bandit still printed INFO messages emitted during option merging (e.g.[main] INFO Using ini file for skipped tests,[main] INFO Found project level .bandit file). The logger was initialized at INFO level at the top ofmain()and only lowered to WARN after argument/ini merging, so anything logged in between (notably_log_option_source()and_get_options_from_ini()) ignored the quiet flag.This applies the same early
sys.argvdetection already used for-d/--debugto the quiet flags, so the logger starts at WARN when quiet is requested. Debug still takes precedence over quiet at startup, and the existing re-initialization logic later inmain()is unchanged.Verified:
bandit --ini .bandit --silent target.pynow emits no INFO lines, while output without--silentis unchanged.Fixes #1250
Changes
bandit/cli/main.py: detect quiet flags insys.argvduring early logger initialization