diff --git a/detect_secrets/plugins/base.py b/detect_secrets/plugins/base.py index bc6540399..2e8bc8a2c 100644 --- a/detect_secrets/plugins/base.py +++ b/detect_secrets/plugins/base.py @@ -239,28 +239,3 @@ def secret_generator(self, string, *args, **kwargs): for regex in self.denylist: for match in regex.findall(string): yield match - - -class WordListSupportedDetector(BasePlugin): - """Parent class for detectors supporting a word list. - - To create a new word list supported detector, subclass this - and pass `automaton` in __init__ like: - - class BarDetector(WordListSupportedDetector): - - secret_type = "bar" - - def __init__(self, automaton=None, **kwargs): - super(BarDetector, self).__init__( - automaton, - **kwargs - ) - ... - """ - __metaclass__ = ABCMeta - - def __init__(self, automaton=None, **kwargs): - super(WordListSupportedDetector, self).__init__(**kwargs) - - self.automaton = automaton diff --git a/detect_secrets/plugins/high_entropy_strings.py b/detect_secrets/plugins/high_entropy_strings.py index caedfc09b..ee3ce363d 100644 --- a/detect_secrets/plugins/high_entropy_strings.py +++ b/detect_secrets/plugins/high_entropy_strings.py @@ -14,7 +14,7 @@ import yaml -from .base import WordListSupportedDetector +from .base import BasePlugin from .common.filetype import determine_file_type from .common.filetype import FileType from .common.filters import is_false_positive @@ -23,7 +23,7 @@ from detect_secrets.core.potential_secret import PotentialSecret -class HighEntropyStringsPlugin(WordListSupportedDetector): +class HighEntropyStringsPlugin(BasePlugin): """Base class for string pattern matching""" __metaclass__ = ABCMeta @@ -38,11 +38,11 @@ def __init__(self, charset, limit, exclude_lines_regex, automaton, *args): self.charset = charset self.entropy_limit = limit + self.automaton = automaton self.regex = re.compile(r'([\'"])([%s]+)(\1)' % charset) super(HighEntropyStringsPlugin, self).__init__( exclude_lines_regex=exclude_lines_regex, - automaton=automaton, ) def analyze(self, file, filename): diff --git a/detect_secrets/plugins/keyword.py b/detect_secrets/plugins/keyword.py index d75269370..ec3edd17b 100644 --- a/detect_secrets/plugins/keyword.py +++ b/detect_secrets/plugins/keyword.py @@ -28,7 +28,7 @@ import re -from .base import WordListSupportedDetector +from .base import BasePlugin from .common.filetype import determine_file_type from .common.filetype import FileType from .common.filters import is_false_positive @@ -247,7 +247,7 @@ } -class KeywordDetector(WordListSupportedDetector): +class KeywordDetector(BasePlugin): """This checks if denylisted keywords are present in the analyzed string. """ @@ -257,7 +257,6 @@ class KeywordDetector(WordListSupportedDetector): def __init__(self, keyword_exclude=None, exclude_lines_regex=None, automaton=None, **kwargs): super(KeywordDetector, self).__init__( exclude_lines_regex=exclude_lines_regex, - automaton=automaton, **kwargs ) @@ -268,6 +267,8 @@ def __init__(self, keyword_exclude=None, exclude_lines_regex=None, automaton=Non re.IGNORECASE, ) + self.automaton = automaton + def analyze_string_content(self, string, line_num, filename): output = {} if (