File tree 4 files changed +21
-0
lines changed 4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -195,3 +195,11 @@ def is_lock_file(filename: str) -> bool:
195
195
'Podfile.lock' ,
196
196
'yarn.lock' ,
197
197
}
198
+
199
+
200
+ def is_not_alphanumeric_string (secret : str ) -> bool :
201
+ """
202
+ This assumes that secrets should have at least ONE letter in them.
203
+ This helps avoid clear false positives, like `*****`.
204
+ """
205
+ return not bool (set (string .ascii_letters ) & set (secret ))
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def clear(self) -> None:
119
119
'detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign' ,
120
120
'detect_secrets.filters.heuristic.is_indirect_reference' ,
121
121
'detect_secrets.filters.heuristic.is_lock_file' ,
122
+ 'detect_secrets.filters.heuristic.is_not_alphanumeric_string' ,
122
123
}
123
124
}
124
125
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ the `detect_secrets.filters` namespace.
51
51
| ` heuristic.is_likely_id_string ` | Ignores secret values prefixed with ` id ` . |
52
52
| ` heuristic.is_lock_file ` | Ignores common lock files. |
53
53
| ` heuristic.is_non_text_file ` | Ignores non-text files (e.g. archives, images). |
54
+ | ` heuristic.is_not_alphanumeric_string ` | Ignores secrets that do not have a single alphanumeric character in it. |
54
55
| ` heuristic.is_potential_uuid ` | Ignores uuid looking secret values. |
55
56
| ` heuristic.is_prefixed_with_dollar_sign ` | Primarily for ` KeywordDetector ` , filters secrets like ` secret = $variableName; ` . |
56
57
| ` heuristic.is_sequential_string ` | Ignores secrets like ` abcdefg ` . |
Original file line number Diff line number Diff line change @@ -130,3 +130,14 @@ def test_is_lock_file():
130
130
131
131
# assert non-regex
132
132
assert not filters .heuristic .is_lock_file ('Gemfilealock' )
133
+
134
+
135
+ @pytest .mark .parametrize (
136
+ 'secret, result' ,
137
+ (
138
+ ('*****' , True ),
139
+ ('a&b23?!' , False ),
140
+ ),
141
+ )
142
+ def test_is_not_alphanumeric_string (secret , result ):
143
+ assert filters .heuristic .is_not_alphanumeric_string (secret ) is result
You can’t perform that action at this time.
0 commit comments