|
14 | 14 | import yaml
|
15 | 15 |
|
16 | 16 | from .base import BasePlugin
|
| 17 | +from .common.filters import is_false_positive |
| 18 | +from .common.ini_file_parser import IniFileParser |
| 19 | +from .common.yaml_file_parser import YamlFileParser |
17 | 20 | from detect_secrets.core.potential_secret import PotentialSecret
|
18 |
| -from detect_secrets.plugins.common.ini_file_parser import IniFileParser |
19 |
| -from detect_secrets.plugins.common.yaml_file_parser import YamlFileParser |
20 |
| - |
21 |
| - |
22 |
| -IGNORED_SEQUENTIAL_STRINGS = ( |
23 |
| - ( |
24 |
| - string.ascii_uppercase + |
25 |
| - string.ascii_uppercase + |
26 |
| - string.digits + |
27 |
| - string.ascii_uppercase + |
28 |
| - string.ascii_uppercase + |
29 |
| - '+/' |
30 |
| - ), |
31 |
| - string.hexdigits.upper() + string.hexdigits.upper(), |
32 |
| - string.ascii_uppercase + '=/', |
33 |
| -) |
| 21 | + |
| 22 | + |
34 | 23 | YAML_EXTENSIONS = (
|
35 | 24 | '.yaml',
|
36 | 25 | '.yml',
|
@@ -97,22 +86,16 @@ def calculate_shannon_entropy(self, data):
|
97 | 86 |
|
98 | 87 | return entropy
|
99 | 88 |
|
100 |
| - def _is_sequential_string(self, string): |
101 |
| - uppercased_string = string.upper() |
102 |
| - for sequential_string in IGNORED_SEQUENTIAL_STRINGS: |
103 |
| - if uppercased_string in sequential_string: |
104 |
| - return True |
105 |
| - return False |
106 |
| - |
107 | 89 | def analyze_string_content(self, string, line_num, filename):
|
108 | 90 | """Searches string for custom pattern, and captures all high entropy strings that
|
109 | 91 | match self.regex, with a limit defined as self.entropy_limit.
|
110 | 92 | """
|
111 | 93 | output = {}
|
112 | 94 |
|
113 | 95 | for result in self.secret_generator(string):
|
114 |
| - if self._is_sequential_string(result): |
| 96 | + if is_false_positive(result): |
115 | 97 | continue
|
| 98 | + |
116 | 99 | secret = PotentialSecret(self.secret_type, filename, result, line_num)
|
117 | 100 | output[secret] = secret
|
118 | 101 |
|
|
0 commit comments