From 4b5f809c1c469e3d2649fb3897a60edf8b277eea Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Mon, 25 May 2026 21:37:32 -0700 Subject: [PATCH] fix(pkg/validation/internal): check nil pointers before dereference --- pkg/validation/internal/community.go | 3 ++- pkg/validation/internal/operatorhub.go | 3 ++- pkg/validation/internal/operatorhubv2.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/validation/internal/community.go b/pkg/validation/internal/community.go index 37473fd31..11c7c9fa7 100644 --- a/pkg/validation/internal/community.go +++ b/pkg/validation/internal/community.go @@ -69,11 +69,12 @@ type CommunityOperatorChecks struct { // validateCommunityBundle will check the bundle against the community-operator criterias func validateCommunityBundle(bundle *manifests.Bundle, indexImagePath string) errors.ManifestResult { - result := errors.ManifestResult{Name: bundle.Name} + result := errors.ManifestResult{} if bundle == nil { result.Add(errors.ErrInvalidBundle("Bundle is nil", nil)) return result } + result.Name = bundle.Name if bundle.CSV == nil { result.Add(errors.ErrInvalidBundle("Bundle csv is nil", bundle.Name)) diff --git a/pkg/validation/internal/operatorhub.go b/pkg/validation/internal/operatorhub.go index fe0edee3a..4b10cc0d6 100644 --- a/pkg/validation/internal/operatorhub.go +++ b/pkg/validation/internal/operatorhub.go @@ -163,12 +163,13 @@ func validateOperatorHubDeprecated(objs ...interface{}) (results []errors.Manife } func validateBundleOperatorHub(bundle *manifests.Bundle, k8sVersion string) errors.ManifestResult { - result := errors.ManifestResult{Name: bundle.Name} + result := errors.ManifestResult{} if bundle == nil { result.Add(errors.ErrInvalidBundle("Bundle is nil", nil)) return result } + result.Name = bundle.Name if bundle.CSV == nil { result.Add(errors.ErrInvalidBundle("Bundle csv is nil", bundle.Name)) diff --git a/pkg/validation/internal/operatorhubv2.go b/pkg/validation/internal/operatorhubv2.go index 64b5aca18..5735ee1b7 100644 --- a/pkg/validation/internal/operatorhubv2.go +++ b/pkg/validation/internal/operatorhubv2.go @@ -33,12 +33,12 @@ func validateOperatorHubV2(objs ...interface{}) (results []errors.ManifestResult } func validateBundleOperatorHubV2(bundle *manifests.Bundle, k8sVersion string) errors.ManifestResult { - result := errors.ManifestResult{Name: bundle.Name} - + result := errors.ManifestResult{} if bundle == nil { result.Add(errors.ErrInvalidBundle("Bundle is nil", nil)) return result } + result.Name = bundle.Name if bundle.CSV == nil { result.Add(errors.ErrInvalidBundle("Bundle csv is nil", bundle.Name))