From 6b613959a571a0b91012ca56780a6cb340a649d9 Mon Sep 17 00:00:00 2001 From: elsapet Date: Tue, 30 Jul 2024 09:25:42 +0200 Subject: [PATCH] feat: error early when pattern var is not found (#1660) --- pkg/scanner/detectors/customrule/filters/filters.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/scanner/detectors/customrule/filters/filters.go b/pkg/scanner/detectors/customrule/filters/filters.go index b4840afc1..2dc9b1a8a 100644 --- a/pkg/scanner/detectors/customrule/filters/filters.go +++ b/pkg/scanner/detectors/customrule/filters/filters.go @@ -1,6 +1,7 @@ package filters import ( + "fmt" "regexp" "slices" "strconv" @@ -203,6 +204,9 @@ func (filter *Rule) Evaluate( patternVariables variableshape.Values, ) (*Result, error) { node := patternVariables.Node(filter.Variable) + if node == nil { + return nil, fmt.Errorf("couldn't find node for var %s", filter.Variable.Name()) + } detections, err := detectorContext.Scan(node, filter.Rule, filter.TraversalStrategy) if err != nil { return nil, err