Merge pull request #5 from mgrove36/fix-regex-processing

[FIX] Incorrect usage of regexp library
This commit is contained in:
Yung Wood
2024-09-01 22:37:02 +09:30
committed by GitHub

View File

@@ -256,16 +256,17 @@ func (smr StringMatchRule) matchesString(data string) bool {
}
// check regex match if set
if smr.RegexMatch != "" {
match, err := regexp.MatchString(data, smr.RegexMatch)
re, err := regexp.Compile(smr.RegexMatch)
if err != nil {
slog.Warn("error processing regex rule", "value", smr.RegexMatch)
return false // regex error is considered a failure to match
slog.Warn("error processing regex rule", "value", smr.RegexMatch)
return false // regex error is considered a failure to match
}
match := re.MatchString(data)
if !match {
return false // regex didn't match
return false // regex didn't match
}
}
return true
return true
}
// EventTransformRules contains VEvent properties that user can modify