diff --git a/pkg/policy/validate.go b/pkg/policy/validate.go index 18843dfd94..7ffc184752 100644 --- a/pkg/policy/validate.go +++ b/pkg/policy/validate.go @@ -997,6 +997,9 @@ func validateConditions(conditions apiextensions.JSON, schemaKey string) (string // validateConditionValues validates whether all the values under the 'value' field of a 'conditions' field // are apt with respect to the provided 'condition.key' func validateConditionValues(c kyverno.Condition) (string, error) { + if c.Key == nil || c.Value == nil || c.Operator == "" { + return "", fmt.Errorf("entered value of `key`, `value` or `operator` is missing or misspelled") + } switch strings.ReplaceAll(c.Key.(string), " ", "") { case "{{request.operation}}": return validateConditionValuesKeyRequestOperation(c)