mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 21:44:23 +01:00
fix: only use non-empty secret groups (#1632)
This commit is contained in:
1 parent
7cb5f6f64c
commit
efe40cae39
1 file changed
-6
@@ -411,11 +411,6 @@ MatchLoop:
|
|||||||
finding.Secret = groups[r.SecretGroup]
|
finding.Secret = groups[r.SecretGroup]
|
||||||
} else {
|
} else {
|
||||||
// If |secretGroup| is not set, we will use the first suitable capture group.
|
// If |secretGroup| is not set, we will use the first suitable capture group.
|
||||||
if len(groups) == 2 {
|
|
||||||
// Use the only group.
|
|
||||||
finding.Secret = groups[1]
|
|
||||||
} else {
|
|
||||||
// Use the first non-empty group.
|
|
||||||
for _, s := range groups[1:] {
|
for _, s := range groups[1:] {
|
||||||
if len(s) > 0 {
|
if len(s) > 0 {
|
||||||
finding.Secret = s
|
finding.Secret = s
|
||||||
@@ -424,7 +419,6 @@ MatchLoop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check if the regexTarget is defined in the allowlist "regexes" entry
|
// check if the regexTarget is defined in the allowlist "regexes" entry
|
||||||
// or if the secret is in the list of stopwords
|
// or if the secret is in the list of stopwords
|
||||||
|
|||||||
Reference in new issue
Block a user