diff --git a/pkg/scanner/detectors/customrule/patternquery/builder/builder.go b/pkg/scanner/detectors/customrule/patternquery/builder/builder.go index 54dd96766..1fee7767f 100644 --- a/pkg/scanner/detectors/customrule/patternquery/builder/builder.go +++ b/pkg/scanner/detectors/customrule/patternquery/builder/builder.go @@ -391,7 +391,7 @@ func getVariableFor( } for i, variable := range variables { - if node.Content() == variable.DummyValue { + if patternLanguage.IsVariable(node, variable.DummyValue) { return &variables[i] } } diff --git a/pkg/scanner/language/pattern.go b/pkg/scanner/language/pattern.go index 78d84557b..ffe536e81 100644 --- a/pkg/scanner/language/pattern.go +++ b/pkg/scanner/language/pattern.go @@ -113,4 +113,7 @@ type Pattern interface { // Handle missing errors FixupMissing(node *tree.Node) string + + // Check if node represents variable with given dummy value + IsVariable(node *tree.Node, dummyValue string) bool } diff --git a/pkg/scanner/language/patternbase.go b/pkg/scanner/language/patternbase.go index 2080b7baf..097353b3f 100644 --- a/pkg/scanner/language/patternbase.go +++ b/pkg/scanner/language/patternbase.go @@ -39,3 +39,7 @@ func (*PatternBase) AdjustInput(input string) string { func (*PatternBase) FixupMissing(node *tree.Node) string { return "" } + +func (*PatternBase) IsVariable(node *tree.Node, dummyValue string) bool { + return node.Content() == dummyValue +}