Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better distinction between high entropy strings #26

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions detect_secrets/plugins/high_entropy_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ def _non_quoted_string_regex(self):
class HexHighEntropyString(HighEntropyStringsPlugin):
"""HighEntropyStringsPlugin for hex strings"""

secret_type = 'Hex High Entropy String'

def __init__(self, limit, *args):
super(HexHighEntropyString, self).__init__(string.hexdigits, limit)


class Base64HighEntropyString(HighEntropyStringsPlugin):
"""HighEntropyStringsPlugin for base64 encoded strings"""

secret_type = 'Base64 High Entropy String'

def __init__(self, limit, *args):
super(Base64HighEntropyString, self).__init__(
string.ascii_letters + string.digits + '+/=',
Expand Down
4 changes: 2 additions & 2 deletions tests/pre_commit_hook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_file_with_secrets(self, mock_log):
'Potential secrets about to be committed to git repo!'
)
assert message_by_lines[2] == \
'Secret Type: High Entropy String'
'Secret Type: Base64 High Entropy String'
assert message_by_lines[3] == \
'Location: test_data/files/file_with_secrets.py:3'

Expand Down Expand Up @@ -158,7 +158,7 @@ def _create_baseline():
'results': {
'test_data/files/file_with_secrets.py': [
{
'type': 'High Entropy String',
'type': 'Base64 High Entropy String',
'line_number': 3,
'hashed_secret': PotentialSecret.hash_secret(base64_secret),
},
Expand Down