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

Add filtering of english words from entropy (and keyword) plugins #241

Merged
merged 26 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d93e9bd
:mortar_board: Standardize `do not` -> `don't`
KevinHock Sep 19, 2019
5b66a26
:snake: Refactor awkward [0] to a short-circuit
KevinHock Sep 19, 2019
bb543c5
:bug: We were doing e.g. '.svg' == 'svg'
KevinHock Sep 19, 2019
f10cce8
:snake: Refactor `for...if...return` with `any`
KevinHock Sep 19, 2019
bc4f922
:snake: Remove is_false_positive from RegexBasedDetector
KevinHock Sep 19, 2019
0b2c0e1
:mortar_board: Standardize comments
KevinHock Sep 19, 2019
f8cb31f
:tada: Add --word-list option
KevinHock Sep 19, 2019
7bdf06f
:100: Coverage for jwt.py
KevinHock Sep 19, 2019
e4494ea
:snake: Separate not :100: covered files
KevinHock Sep 19, 2019
d3c9583
:snake: Make automaton case-insensitive
KevinHock Sep 19, 2019
9e3669d
:snake: Slightly better condition for is_verified = True
KevinHock Sep 19, 2019
7ce4b85
:telescope: Don't put words less than 4 chars in automaton
KevinHock Sep 20, 2019
de7fbd2
:100: Coverage for high_entropy_strings.py
KevinHock Sep 20, 2019
139c64a
:snake: Refactor `audit --display-results` code
KevinHock Sep 21, 2019
6c6e028
:mortar_board: Use plural variable name for list
KevinHock Sep 21, 2019
977c4fb
:tada: Add verification for Mailchimp API keys
KevinHock Sep 21, 2019
9cabbe0
:tada: Add verification for Stripe secret API keys
KevinHock Sep 21, 2019
20d1921
:100: Coverage for baseline.py initialize.py usage.py
KevinHock Sep 21, 2019
433b75e
:snake: Add stats to `audit --display-results` code
KevinHock Sep 23, 2019
a096600
:performing_arts: Add more to `IGNORED_FILE_EXTENSIONS`
KevinHock Sep 23, 2019
ef5d000
:bug: Fix auditing a baseline with MailChimp in it
KevinHock Sep 23, 2019
a493356
:bug: Fix TypeError thrown when Yaml was all comments
KevinHock Sep 23, 2019
171eeca
:bug: Fix scanning files that don't exist
KevinHock Sep 23, 2019
69a3aac
:snake: Use hash.update to be more succinct
KevinHock Sep 24, 2019
19d22da
:snake: Inline leading . in constants.py
KevinHock Sep 24, 2019
b440623
:snake: Remove useless WordListSupportedDetector class
KevinHock Sep 24, 2019
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
Prev Previous commit
Next Next commit
🎓 Use plural variable name for list
  • Loading branch information
KevinHock committed Sep 21, 2019
commit 6c6e028210261bb15745599db33622eb49a1c342
8 changes: 4 additions & 4 deletions detect_secrets/plugins/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ class AWSKeyDetector(RegexBasedDetector):
)

def verify(self, token, content):
secret_access_key = get_secret_access_key(content)
if not secret_access_key:
secret_access_key_candidates = get_secret_access_keys(content)
if not secret_access_key_candidates:
return VerifiedResult.UNVERIFIED

for candidate in secret_access_key:
for candidate in secret_access_key_candidates:
if verify_aws_secret_access_key(token, candidate):
return VerifiedResult.VERIFIED_TRUE

return VerifiedResult.VERIFIED_FALSE


def get_secret_access_key(content):
def get_secret_access_keys(content):
# AWS secret access keys are 40 characters long.
regex = re.compile(
r'= *([\'"]?)([%s]{40})(\1)$' % (
Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/aws_key_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from detect_secrets.core.constants import VerifiedResult
from detect_secrets.plugins.aws import AWSKeyDetector
from detect_secrets.plugins.aws import get_secret_access_key
from detect_secrets.plugins.aws import get_secret_access_keys
from testing.mocks import mock_file_object


Expand Down Expand Up @@ -119,7 +119,7 @@ def counter(*args, **kwargs):
[EXAMPLE_SECRET],
),

# multiple candidates
# Multiple candidates
(
textwrap.dedent("""
base64_keyA = '{}'
Expand All @@ -142,4 +142,4 @@ def counter(*args, **kwargs):
),
)
def test_get_secret_access_key(content, expected_output):
assert get_secret_access_key(content) == expected_output
assert get_secret_access_keys(content) == expected_output