Skip to content

Commit

Permalink
fix: only use non-empty secret groups (#1632)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmz authored Dec 21, 2024
1 parent 7cb5f6f commit efe40ca
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions detect/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,10 @@ MatchLoop:
finding.Secret = groups[r.SecretGroup]
} else {
// 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:] {
if len(s) > 0 {
finding.Secret = s
break
}
for _, s := range groups[1:] {
if len(s) > 0 {
finding.Secret = s
break
}
}
}
Expand Down

0 comments on commit efe40ca

Please sign in to comment.