diff --git a/detect_secrets/plugins/base.py b/detect_secrets/plugins/base.py index 457625d9a..0ce60809a 100644 --- a/detect_secrets/plugins/base.py +++ b/detect_secrets/plugins/base.py @@ -1,6 +1,8 @@ from abc import ABCMeta from abc import abstractmethod +from detect_secrets.plugins.core.constants import WHITELIST_REGEX + class BasePlugin(object): """This is an abstract class to define Plugins API""" @@ -23,6 +25,8 @@ def analyze(self, file, filename): """ potential_secrets = {} for line_num, line in enumerate(file.readlines(), start=1): + if WHITELIST_REGEX.search(line): + continue secrets = self.analyze_string(line, line_num, filename) potential_secrets.update(secrets) diff --git a/detect_secrets/plugins/keyword.py b/detect_secrets/plugins/keyword.py index 5ce4d461b..aa865f93c 100644 --- a/detect_secrets/plugins/keyword.py +++ b/detect_secrets/plugins/keyword.py @@ -28,7 +28,6 @@ from .base import BasePlugin from detect_secrets.core.potential_secret import PotentialSecret -from detect_secrets.plugins.core.constants import WHITELIST_REGEX BLACKLIST = ( @@ -54,9 +53,6 @@ class KeywordDetector(BasePlugin): def analyze_string(self, string, line_num, filename): output = {} - if WHITELIST_REGEX.search(string): - return output - for identifier in self.secret_generator(string): secret = PotentialSecret( self.secret_type, diff --git a/test_data/config.ini b/test_data/config.ini index 2304d2fdd..97f5e14b4 100644 --- a/test_data/config.ini +++ b/test_data/config.ini @@ -22,3 +22,5 @@ keyB = 456789123 567891234 keyC = + +password = 12345678901234 # pragma: whitelist secret