From 7592006ec3e862b670b0f336f3dcee8780280a2a Mon Sep 17 00:00:00 2001 From: Vickey Brown Date: Tue, 7 Jul 2026 08:50:43 -0500 Subject: [PATCH] Fix manual remediation script discovery for rules with dashes/underscores --- helpers/utilities.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/helpers/utilities.go b/helpers/utilities.go index 4a8f5afe..faa2ea35 100644 --- a/helpers/utilities.go +++ b/helpers/utilities.go @@ -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) {