Skip to content

Commit

Permalink
case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
zricethezav committed Jul 25, 2023
1 parent f393034 commit 6cc5cab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ func Start(ctx context.Context, options ...EngineOption) *Engine {
// on keywords
keywords := []string{}
for _, d := range e.detectors[false] {
keywords = append(keywords, d.Keywords()...)
for _, kw := range d.Keywords() {
keywords = append(keywords, strings.ToLower(kw))
}
}
for _, d := range e.detectors[true] {
keywords = append(keywords, d.Keywords()...)
for _, kw := range d.Keywords() {
keywords = append(keywords, strings.ToLower(kw))
}
}
e.prefilter = *ahocorasick.NewTrieBuilder().AddStrings(keywords).Build()

Expand Down Expand Up @@ -291,7 +295,7 @@ func (e *Engine) detectorWorker(ctx context.Context) {
}

// build a map of all keywords that were matched in the chunk
for _, m := range e.prefilter.MatchString(string(decoded.Data)) {
for _, m := range e.prefilter.MatchString(strings.ToLower(string(decoded.Data))) {
matchedKeywords[strings.ToLower(m.MatchString())] = struct{}{}
}

Expand Down

0 comments on commit 6cc5cab

Please sign in to comment.