Add experimental allowlist optimizations (#1731)

* feat(allowlist): optimization experiments

* refactor(allowlist): remove useOptimizations flag

* refactor(allowlist): simplify Validate() with helper func

* refactor(config): replace global feature flag
This commit is contained in:
Richard Gomez authored and GitHub committed 2025-06-08 10:33:05 -05:00
1 parent 79068b35e5
commit 9faaa4a09c
9 files changed
+363 -42

No files matched your search

+16
View File
@@ -1,6 +1,8 @@
package config
import (
"strings"
"github.com/zricethezav/gitleaks/v8/regexp"
)
@@ -22,3 +24,17 @@ func regexMatched(f string, re *regexp.Regexp) bool {
}
return false
}
// joinRegexOr combines multiple |patterns| into a single *regexp.Regexp.
func joinRegexOr(patterns []*regexp.Regexp) *regexp.Regexp {
var sb strings.Builder
sb.WriteString("(?:")
for i, pat := range patterns {
sb.WriteString(pat.String())
if i != len(patterns)-1 {
sb.WriteString("|")
}
}
sb.WriteString(")")
return regexp.MustCompile(sb.String())
}