Skip to content

Commit

Permalink
[private key plugin] Change analyze_string output dict to have Potent…
Browse files Browse the repository at this point in the history
…ialSecret as the key, not filename
  • Loading branch information
KevinHock committed Apr 6, 2018
1 parent afe6f0b commit 4f76df4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion detect_secrets/plugins/private_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def analyze_string(self, string, line_num, filename):
output = {}

if any(line in string for line in BLACKLIST):
output[filename] = PotentialSecret(
secret = PotentialSecret(
self.secret_type,
filename,
line_num,
string,
)
output[secret] = secret

return output
5 changes: 4 additions & 1 deletion tests/plugins/private_key_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ def test_analyze(self):
)

f = create_file_object_from_string(file_content)
assert 'mock_filename' in logic.analyze(f, 'mock_filename')
output = logic.analyze(f, 'mock_filename')
assert len(output) == 1
for potential_secret in output:
assert 'mock_filename' == potential_secret.filename

0 comments on commit 4f76df4

Please sign in to comment.