diff --git a/pkg/engine/context/evaluate.go b/pkg/engine/context/evaluate.go index 722c9428b3..124731ced1 100644 --- a/pkg/engine/context/evaluate.go +++ b/pkg/engine/context/evaluate.go @@ -10,9 +10,14 @@ import ( //Query the JSON context with JMESPATH search path func (ctx *Context) Query(query string) (interface{}, error) { + query = strings.TrimSpace(query) + if query == "" { + return nil, fmt.Errorf("invalid query (nil)") + } + var emptyResult interface{} // check for white-listed variables - if !ctx.isWhiteListed(query) { + if !ctx.isBuiltInVariable(query) { return emptyResult, fmt.Errorf("variable %s cannot be used", query) } @@ -40,7 +45,7 @@ func (ctx *Context) Query(query string) (interface{}, error) { return result, nil } -func (ctx *Context) isWhiteListed(variable string) bool { +func (ctx *Context) isBuiltInVariable(variable string) bool { if len(ctx.builtInVars) == 0 { return true }