Skip to content

Commit 4ce9556

Browse files
committed
Do not try to remove password plugin reported secrets even if other plugins report that same line, change PotentialSecret .type back to a single string
1 parent 29b3b78 commit 4ce9556

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

detect_secrets/core/potential_secret.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def __init__(
2323
is_secret=None,
2424
):
2525
"""
26-
:type typ: list(str)
26+
:type typ: str
2727
:param typ: human-readable secret types, defined by the plugins
2828
that generated this PotentialSecret.
29-
e.g. ["High Entropy String"]
29+
e.g. "High Entropy String"
3030
3131
:type filename: str
3232
:param filename: name of file that this secret was found
@@ -41,7 +41,7 @@ def __init__(
4141
:type is_secret: bool|None
4242
:param is_secret: whether or not the secret is a true- or false- positive
4343
"""
44-
self.type = [typ]
44+
self.type = typ
4545
self.filename = filename
4646
self.lineno = lineno
4747
self.secret_hash = self.hash_secret(secret)

detect_secrets/core/secrets_collection.py

-30
Original file line numberDiff line numberDiff line change
@@ -259,41 +259,11 @@ def _results_accumulator(self, filename):
259259
if not file_results:
260260
return
261261

262-
self._remove_keyword_secrets_if_line_reported_already(
263-
file_results,
264-
)
265-
266262
if filename not in self.data:
267263
self.data[filename] = file_results
268264
else:
269265
self.data[filename].update(file_results)
270266

271-
def _remove_keyword_secrets_if_line_reported_already(
272-
self,
273-
file_results,
274-
):
275-
"""
276-
It is often the case that e.g.
277-
SUPER_SECRET_VALUE = 'c3VwZXIgbG9uZyBzdHJ'
278-
is reported both by the KeywordDetector and another plugin.
279-
280-
To minimize diff size, we will simply not report findings from
281-
the KeywordDetector if another plugin reports a secret on the
282-
same line.
283-
"""
284-
password_secrets = list()
285-
line_numbers_of_other_plugins = set()
286-
287-
for secret in file_results:
288-
if secret.type == 'Password':
289-
password_secrets.append(secret)
290-
else:
291-
line_numbers_of_other_plugins.add(secret.lineno)
292-
293-
for password_secret in password_secrets:
294-
if password_secret.lineno in line_numbers_of_other_plugins:
295-
del file_results[password_secret]
296-
297267
def _extract_secrets_from_file(self, f, filename):
298268
"""Extract secrets from a given file object.
299269

0 commit comments

Comments
 (0)