-
-
Save Daviey/6f61e86cc19e6e51ff95 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/bandit/bandit.py b/bandit/bandit.py | |
index 1f4fdbd..c27b75a 100644 | |
--- a/bandit/bandit.py | |
+++ b/bandit/bandit.py | |
@@ -47,7 +47,7 @@ def _init_logger(debug=False, log_format=None): | |
log_format_string = log_format | |
logging.captureWarnings(True) | |
- warnings.formatwarning = _warning | |
+ warnings.formatwarning = utils.warnings_formatter | |
logger = logging.getLogger() | |
logger.setLevel(log_level) | |
@@ -85,15 +85,6 @@ def _find_config(): | |
raise utils.NoConfigFileFound(config_locations) | |
-def _warning(message, | |
- category=UserWarning, | |
- filename='', | |
- lineno=-1, | |
- line=''): | |
- '''Monkey patch for warnings.warn to suppress cruft output.''' | |
- return "{0}\n".format(message) | |
- | |
- | |
def main(): | |
# bring our logging stuff up as early as possible | |
debug = ('-d' in sys.argv or '--debug' in sys.argv) | |
diff --git a/bandit/core/tester.py b/bandit/core/tester.py | |
index 91c00b4..78ebd4e 100644 | |
--- a/bandit/core/tester.py | |
+++ b/bandit/core/tester.py | |
@@ -21,10 +21,12 @@ import six | |
from bandit.core import constants | |
from bandit.core import context as b_context | |
+from bandit.core import utils | |
class BanditTester(): | |
+ warnings.formatwarning = utils.warnings_formatter | |
results = None | |
def __init__(self, logger, config, results, testset, debug): | |
diff --git a/bandit/core/utils.py b/bandit/core/utils.py | |
index e64a762..3077850 100644 | |
--- a/bandit/core/utils.py | |
+++ b/bandit/core/utils.py | |
@@ -188,6 +188,15 @@ class NoConfigFileFound(Exception): | |
super(NoConfigFileFound, self).__init__(message) | |
+def warnings_formatter(message, | |
+ category=UserWarning, | |
+ filename='', | |
+ lineno=-1, | |
+ line=''): | |
+ '''Monkey patch for warnings.warn to suppress cruft output.''' | |
+ return "{0}\n".format(message) | |
+ | |
+ | |
def get_module_qualname_from_path(path): | |
'''Get the module's qualified name by analysis of the path. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment