Skip to content

Commit d912ced

Browse files
committed
Add whitelist to Keyword plugin, fix the rest of the tests
1 parent e4911bf commit d912ced

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

Diff for: detect_secrets/core/potential_secret.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(
2424
):
2525
"""
2626
:type typ: str
27-
:param typ: human-readable secret types, defined by the plugins
27+
:param typ: human-readable secret type, defined by the plugin
2828
that generated this PotentialSecret.
2929
e.g. "High Entropy String"
3030

Diff for: detect_secrets/plugins/keyword.py

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
from .base import BasePlugin
3030
from detect_secrets.core.potential_secret import PotentialSecret
31+
from detect_secrets.plugins.core.constants import WHITELIST_REGEX
3132

3233

3334
BLACKLIST = (
@@ -51,6 +52,9 @@ class KeywordDetector(BasePlugin):
5152
def analyze_string(self, string, line_num, filename):
5253
output = {}
5354

55+
if WHITELIST_REGEX.search(string):
56+
return output
57+
5458
for identifier in self.secret_generator(string.lower()):
5559
secret = PotentialSecret(
5660
self.secret_type,

Diff for: test_data/files/file_with_secrets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python
22
# Will change this later.
3-
SUPER_SECRET_VALUE = 'c3VwZXIgbG9uZyBzdHJpbmcgc2hvdWxkIGNhdXNlIGVub3VnaCBlbnRyb3B5'
3+
SUPER_SEECRET_VALUE = 'c3VwZXIgbG9uZyBzdHJpbmcgc2hvdWxkIGNhdXNlIGVub3VnaCBlbnRyb3B5'
44
VERY_SECRET_TOO = 'f6CGV4aMM9zedoh3OUNbSakBymo7yplB' # pragma: whitelist secret
55

66

Diff for: test_data/short_files/first_line.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
secret = 'BEEF0123456789a'
1+
seecret = 'BEEF0123456789a'
22
skipped_sequential_false_positive = '0123456789a'
33
print('second line')
44
var = 'third line'

Diff for: tests/main_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_old_baseline_ignored_with_update_flag(
181181
(
182182
'test_data/short_files/first_line.py',
183183
textwrap.dedent("""
184-
1:secret = 'BEEF0123456789a'
184+
1:seecret = 'BEEF0123456789a'
185185
2:skipped_sequential_false_positive = '0123456789a'
186186
3:print('second line')
187187
4:var = 'third line'

0 commit comments

Comments
 (0)