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

Extend keywords #656

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.6', '3.7', '3.8', '3.9']
python: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python: ['3.6', '3.7', '3.8', '3.9']
python: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
2 changes: 2 additions & 0 deletions detect_secrets/plugins/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
'key_?pass',
'password',
'passwd',
'token',
'_pass\\b',
'pwd',
'secret',
'contraseña',
Expand Down
7 changes: 7 additions & 0 deletions tests/plugins/keyword_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
("api_key: '{}'".format(WHITES_SECRET), WHITES_SECRET),
('aws_secret_access_key: {}'.format(WHITES_SECRET), WHITES_SECRET),
('db_pass: {},'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('my_pass: {},'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('passwd: {}`'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('token: {}`'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('private_key: {}"'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
("secret: {}'".format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('secrete "{}";'.format(COMMON_SECRET), COMMON_SECRET),
Expand Down Expand Up @@ -54,6 +56,7 @@
('db_pass := {}'.format(COMMON_SECRET), COMMON_SECRET),
('db_pass_secure := {}'.format(COMMON_SECRET), COMMON_SECRET), # Suffix
('passwd := {},'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('token := {},'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
("private_key := {}'".format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('secret := {}"'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
('password := {}`'.format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
Expand Down Expand Up @@ -93,6 +96,7 @@
('password = @"{}";'.format(COMMON_SECRET), COMMON_SECRET),
('my_password_secure = @"{}";'.format(COMMON_SECRET), COMMON_SECRET), # Prefix/suffix
('secrete[] = "{}";'.format(COMMON_SECRET), COMMON_SECRET),
('token = "{}";'.format(COMMON_SECRET), COMMON_SECRET),
('char secrete[25] = "{}";'.format(COMMON_SECRET), COMMON_SECRET),
('secrete = "{}"'.format(LETTER_SECRET), LETTER_SECRET), # All symbols are allowed
('password = "{}"'.format(SYMBOL_SECRET), None), # At least 1 alphanumeric char is required
Expand All @@ -111,6 +115,7 @@

C_PLUS_PLUS_TEST_CASES = [
('apikey = "{}";'.format(COMMON_SECRET), COMMON_SECRET),
('token = "{}";'.format(COMMON_SECRET), COMMON_SECRET),
('my_password_secure = "{}";'.format(COMMON_SECRET), COMMON_SECRET), # Prefix and suffix
('password = {}'.format(COMMON_SECRET), None), # Secret without quotes
('if (secret == "{}")'.format(COMMON_SECRET), COMMON_SECRET), # Comparison
Expand All @@ -129,7 +134,9 @@
('api_key: `{}`'.format(COMMON_SECRET), COMMON_SECRET),
("aws_secret_access_key: '{}'".format(COMMON_SECRET), COMMON_SECRET),
("db_pass: '{}'".format(LETTER_SECRET), LETTER_SECRET), # All symbols are allowed
("my_pass: '{}',".format(COMMON_SECRET), COMMON_SECRET), # Last character is ignored
("password: '{}'".format(SYMBOL_SECRET), None), # At least 1 alphanumeric character is required
("token: '{}'".format(COMMON_SECRET), COMMON_SECRET),
('if ("{}" == passwd) {{'.format(COMMON_SECRET), COMMON_SECRET),
('if ("{}" === private_key) {{'.format(COMMON_SECRET), COMMON_SECRET),
('if ("{}" === my_private_key) {{'.format(COMMON_SECRET), COMMON_SECRET), # Prefix
Expand Down