From 0315891f092fcf2dc519eecde4f82e2b0f75ea7c Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Thu, 4 Jan 2024 13:50:29 -0500 Subject: [PATCH] :bug: Escape parentheses before where substitution Signed-off-by: Fabian von Feilitzsch --- pkg/conversion/convert.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/conversion/convert.go b/pkg/conversion/convert.go index 8035a2e..75f7a86 100644 --- a/pkg/conversion/convert.go +++ b/pkg/conversion/convert.go @@ -371,7 +371,7 @@ func convertWindupWhenToAnalyzer(windupWhen windup.When, where map[string]string //} condition := map[string]interface{}{ "builtin.filecontent": map[string]interface{}{ - "pattern": convertWindupRegex(substituteWhere(where, fc.Pattern)), + "pattern": convertWindupRegex(substituteWhere(where, escapeParens(fc.Pattern))), "filePattern": escapeDots(convertWindupRegex(substituteWhere(where, fc.Filename))), }, } @@ -976,3 +976,9 @@ func convertWindupRegex(regex string) string { } return regex } + +func escapeParens(s string) string { + s = strings.Replace(s, "(", "\\(", -1) + s = strings.Replace(s, ")", "\\)", -1) + return s +}