mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
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:
1 parent
79068b35e5
commit
9faaa4a09c
9 files changed
+363
-42
No files matched your search
@@ -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())
|
||||
}
|
||||
Reference in new issue
Block a user