awslabs / awslabs/git-secrets

Pattern being incorrectly matched

Open
#185 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
13.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I am running git-secrets on Windows, using the latest master-branch source.

I have a currently empty config.json file to store a token for an application:

```
{
"Token": ""
}
```

I am attempting to write a rule to pick up non-blank tokens. I have tried several variations:

```
git secrets --add '"Token": ".+"'
git secrets --add '\"Token\": \".+\"'
git secrets --add '\"Token\": \".+?\"
git secrets --add '\"Token\": \"[a-zA-Z0-9_]+\"'
git secrets --add '\"Token\"\: \"[a-zA-Z0-9_]+\"'
```

The first rule ends up matching every line in every file. I think this is an issue with the quote character being escaped.

Every other rule I have flags the 2nd line of config.json (below) as matching the prohibited pattern.

```
config.json:2: "Token": ""

[ERROR] Matched one or more prohibited patterns
```

However in all of these cases I'm looking for a non-empty token string, and the + operator should be doing that for me. I'm really not sure what's going on here. I'm not the sharpest with RegEx but this should be correct and I've tested with several online tools which all validate this as well.

Thanks,
Charlie

Contributor guide

Open the contributing guide

Research direction

Reproduce the report on Windows with an empty config.json and the shown git secrets --add patterns, then trace how the CLI parses and applies the rule. Done means the pattern does not match the empty "Token" value but does match a non-empty token, without matching unrelated lines.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.