awslabs / awslabs/git-secrets

Allowed pattern matches override all other prohibited pattern matches

Open
#69 1 comment 0 reactions 0 assignees View on GitHub
aged
Dominant language
Shell
Stars
13.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

When a single line matches both a prohibited pattern **and** an allowed pattern, then the entire line is allowed, regardless of whether they match the same string. As a simple test you can repro this with the following:

```
echo 'THIS_IS_SECRET but THIS_IS_NOT' > ./test-file
git secrets --add --literal THIS_IS_SECRET
git secrets --add --allowed THIS_IS_NOT
git secrets --scan ./test-file
```

My expectation is that since the prohibited and allowed matches are not for the same string, that the file is still flagged as containing a secret, but instead the entire line is ignored even though the allowed match is not the same as the prohibited match. This makes creating allowed patterns very difficult since you must test extensively to ensure the allowed pattern does not create false negatives, hiding legitimate secrets that you want to prevent from being checked in.

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior with the commands in the issue, using a file containing both THIS_IS_SECRET and THIS_IS_NOT. Start at the scan path that applies allowed and prohibited patterns, then verify that a distinct prohibited match on the same line is still reported. Done means the example file is flagged despite the allowed match.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.