Skip to content

Commit 8450ad7

Browse files
authored
Merge pull request #89 from dbraley/master
Adjust regexp for aws iam resource keys to check for valid prefixes
2 parents d8da475 + 79a73d8 commit 8450ad7

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ Installing git-secrets
3535
~~~~~~~~~~~~~~~~~~~~~~
3636

3737
``git-secrets`` must be placed somewhere in your PATH so that it is picked up
38-
by ``git`` when running ``git secrets``.
38+
by ``git`` when running ``git secrets``.
3939

4040
**\*nix (Linux/OSX)**
4141

42-
You can use ``install`` target of the provided Makefile to install
42+
You can use ``install`` target of the provided Makefile to install
4343
``git secrets`` and the man page. You can customize the install path
4444
using the PREFIX and MANPREFIX variables.
4545

@@ -161,7 +161,7 @@ Each of these options must appear first on the command line.
161161
in ``~/.aws/credentials`` are not found in any commit. The following
162162
checks are added:
163163

164-
- AWS Access Key ID via ``[A-Z0-9]{20}``
164+
- AWS Access Key ID via ``(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}``
165165
- AWS Secret Access Key assignments via ":" or "=" surrounded by optional
166166
quotes
167167
- AWS account ID assignments via ":" or "=" surrounded by optional quotes
@@ -415,7 +415,7 @@ regular expression patterns as false positives using the following command:
415415

416416
git secrets --add --allowed 'my regex pattern'
417417

418-
You can also add regular expressions patterns to filter false positives to a
418+
You can also add regular expressions patterns to filter false positives to a
419419
.gitallowed file located in the repository's root directory. Lines starting
420420
with # are skipped (comment line) and empty lines are also skipped.
421421

git-secrets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ register_aws() {
235235
local aws="(AWS|aws|Aws)?_?" quote="(\"|')" connect="\s*(:|=>|=)\s*"
236236
local opt_quote="${quote}?"
237237
add_config 'secrets.providers' 'git secrets --aws-provider'
238-
add_config 'secrets.patterns' '[A-Z0-9]{20}'
238+
add_config 'secrets.patterns' '(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'
239239
add_config 'secrets.patterns' "${opt_quote}${aws}(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)${opt_quote}${connect}${opt_quote}[A-Za-z0-9/\+=]{40}${opt_quote}"
240240
add_config 'secrets.patterns' "${opt_quote}${aws}(ACCOUNT|account|Account)_?(ID|id|Id)?${opt_quote}${connect}${opt_quote}[0-9]{4}\-?[0-9]{4}\-?[0-9]{4}${opt_quote}"
241241
add_config 'secrets.allowed' 'AKIAIOSFODNN7EXAMPLE'

test/git-secrets.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ load test_helper
278278
repo_run git-secrets --register-aws
279279
git config --local --get secrets.providers
280280
repo_run git-secrets --list
281-
echo "$output" | grep -F '[A-Z0-9]{20}'
281+
echo "$output" | grep -F '(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'
282282
echo "$output" | grep "AKIAIOSFODNN7EXAMPLE"
283283
echo "$output" | grep "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
284284
}

0 commit comments

Comments
 (0)