1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 18:38:40 +00:00

fix: panic for nil rule response when processing old object (#11550)

Signed-off-by: ShutingZhao <shuting@nirmata.com>
This commit is contained in:
shuting 2024-11-07 17:48:33 +08:00 committed by GitHub
parent 6b99fb0653
commit a26f588b86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -164,7 +164,8 @@ func (v *validator) validate(ctx context.Context) *engineapi.RuleResponse {
}
// when an existing resource violates, and the updated resource also violates, then skip
if ruleResponse.Status() == engineapi.RuleStatusFail && priorResp.Status() == engineapi.RuleStatusFail { //
if ruleResponse.Status() == engineapi.RuleStatusFail &&
(priorResp != nil && priorResp.Status() == engineapi.RuleStatusFail) { //
v.log.V(2).Info("warning: skipping the rule evaluation as pre-existing violations are allowed", "ruleResponse", ruleResponse, "priorResp", priorResp)
return engineapi.RuleSkip(v.rule.Name, engineapi.Validation, "skipping the rule evaluation as pre-existing violations are allowed", v.rule.ReportProperties)
}