Compare commits

...
1 Commits
Author SHA1 Message Date
Zachary Rice d8cd93cabe maybe fix out of bounds (#843) 2022-04-18 14:57:40 -05:00
2 changed files with 7 additions and 3 deletions

No files matched your search

+4 -1
View File
@@ -4,6 +4,7 @@ import (
_ "embed"
"fmt"
"regexp"
"strings"
)
//go:embed gitleaks.toml
@@ -64,7 +65,9 @@ func (vc *ViperConfig) Translate() (Config, error) {
if r.Keywords == nil {
r.Keywords = []string{}
} else {
keywords = append(keywords, r.Keywords...)
for _, k := range r.Keywords {
keywords = append(keywords, strings.ToLower(k))
}
}
if r.Tags == nil {
+3 -2
View File
@@ -393,9 +393,10 @@ func (d *Detector) Detect(fragment Fragment) []report.Finding {
fragment.newlineIndices = regexp.MustCompile("\n").FindAllStringIndex(fragment.Raw, -1)
// build keyword map for prefiltering rules
matches := d.prefilter.FindAll(strings.ToLower(fragment.Raw))
normalizedRaw := strings.ToLower(fragment.Raw)
matches := d.prefilter.FindAll(normalizedRaw)
for _, m := range matches {
fragment.keywords[strings.ToLower(fragment.Raw[m.Start():m.End()])] = true
fragment.keywords[normalizedRaw[m.Start():m.End()]] = true
}
for _, rule := range d.Config.Rules {