Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions helpers/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,11 +1115,16 @@ func getRuleNameFromResultName(

func convertRuleNameToRegex(ruleName string) string {
// Escape any special regex characters in the rule name
escaped := regexp.QuoteMeta(ruleName)
// Replace literal \- and \_ with a character class that matches both - and _
pattern := strings.ReplaceAll(escaped, `\-`, `[-_]`)
pattern = strings.ReplaceAll(pattern, `\_`, `[-_]`)
return pattern
pattern := ""
for _, char := range ruleName {
if char == '-' || char == '_' {
pattern += `[-_]`
} else {
// Escape this individual character if it's a regex metacharacter
pattern += regexp.QuoteMeta(string(char))
}
}
return pattern
}

func findRulePath(tc *testConfig.TestConfig, rulePattern string) (rulePath string, found bool) {
Expand Down