Commit 52ba5e9
committed
fix(detectors): skip GitLab v1 candidates with no digits to reduce false positives
The v1 GitLab detector uses PrefixRegex which searches up to 40 chars
ahead of a "gitlab" keyword, crossing newlines. In Dockerfiles like:
ARG GITLAB_ACCESS_TOKEN_TYPE=Private-Token
ARG GITLAB_ACCESS_TOKEN
ARG MAVEN_SETTINGS_PROFILE=test
"MAVEN_SETTINGS_PROFILE" (22 chars, all [a-zA-Z0-9_]) is within 40
characters of the second GITLAB keyword and passes the Shannon entropy
check (~4.1 > 3.6) because its letters are varied. It is then reported
as a GitLab secret — a false positive.
Real GitLab personal access tokens are randomly generated and always
contain at least one digit. Variable names like MAVEN_SETTINGS_PROFILE
never do. Add a KeyIsRandom guard (already used elsewhere in the
codebase) to discard digit-free candidates before verification.
Closes #4756
Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>1 parent 9f0b97f commit 52ba5e9
2 files changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
| |||
0 commit comments