From efe40cae390ca7c9a66d341dc21b8004193a23cd Mon Sep 17 00:00:00 2001 From: Richard Gomez <32133502+rgmz@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:53:44 -0500 Subject: [PATCH] fix: only use non-empty secret groups (#1632) --- detect/detect.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/detect/detect.go b/detect/detect.go index b4b7c949..8ef807be 100644 --- a/detect/detect.go +++ b/detect/detect.go @@ -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 } } }