From d3f0997bf041894ac4944b08d1a1359219d33cae Mon Sep 17 00:00:00 2001 From: otterobert <154877877+otterobert@users.noreply.github.com> Date: Sun, 15 Dec 2024 16:06:51 +0200 Subject: [PATCH] Prevent nil pointer access in otterize crds (#534) --- .../controllers/custom_resource_definition_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operator/controllers/custom_resource_definition_controller.go b/src/operator/controllers/custom_resource_definition_controller.go index b321bb352..a5f50fcc1 100644 --- a/src/operator/controllers/custom_resource_definition_controller.go +++ b/src/operator/controllers/custom_resource_definition_controller.go @@ -73,7 +73,7 @@ func (r *CustomResourceDefinitionsReconciler) Reconcile(ctx context.Context, req } resourceCopy := crd.DeepCopy() resourceCopy.Spec = baseCRD.Spec - if resourceCopy.Spec.Conversion == nil || resourceCopy.Spec.Conversion.Webhook == nil || resourceCopy.Spec.Conversion.Webhook.ClientConfig == nil { + if resourceCopy.Spec.Conversion == nil || resourceCopy.Spec.Conversion.Webhook == nil || resourceCopy.Spec.Conversion.Webhook.ClientConfig == nil || resourceCopy.Spec.Conversion.Webhook.ClientConfig.Service == nil { return ctrl.Result{}, errors.Errorf("CRD does not contain a proper conversion webhook definition") } if bytes.Equal(crd.Spec.Conversion.Webhook.ClientConfig.CABundle, r.certPem) && crd.Spec.Conversion.Webhook.ClientConfig.Service.Namespace == r.namespace {