diff --git a/go.mod b/go.mod index 4ab14213..f3b032b7 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/openshift/api v0.0.0-20251015135203-5d856d3e8354 github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 github.com/operator-framework/api v0.41.0 - github.com/operator-framework/operator-manifest-tools v0.11.0 + github.com/operator-framework/operator-manifest-tools v0.12.0 github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 github.com/sirupsen/logrus v1.9.4 github.com/spf13/afero v1.15.0 diff --git a/go.sum b/go.sum index 8eecd494..e8191077 100644 --- a/go.sum +++ b/go.sum @@ -181,8 +181,8 @@ github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 h1:9JBeIXmnHlp github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235/go.mod h1:L49W6pfrZkfOE5iC1PqEkuLkXG4W0BX4w8b+L2Bv7fM= github.com/operator-framework/api v0.41.0 h1:B0nutndl95elbLXJGRlkFNTI8OuZIjSqvTEeORPhTKo= github.com/operator-framework/api v0.41.0/go.mod h1:Ouud+eqruzll9X3iv8wuAOTNAyyEncYXp4IVgbIlIdg= -github.com/operator-framework/operator-manifest-tools v0.11.0 h1:4qJ6c2XqPSKzlqyyM41bCEfN/+tYQsDwWckW0vL8rlk= -github.com/operator-framework/operator-manifest-tools v0.11.0/go.mod h1:Tp0cSG7X7/6k6tmKLeEpPq5f1fw6RiqwyfoNIWOz6v8= +github.com/operator-framework/operator-manifest-tools v0.12.0 h1:RZU49mLdyHv2C9OMXuQXMYteKan6LahX5P66r1iLrYw= +github.com/operator-framework/operator-manifest-tools v0.12.0/go.mod h1:Qe6H69HTSnzdMZxDZ584yQAr/+hQwEeEZI0NwmHbigg= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/internal/policy/operator/certified_images_test.go b/internal/policy/operator/certified_images_test.go index af003247..b13e2c9a 100644 --- a/internal/policy/operator/certified_images_test.go +++ b/internal/policy/operator/certified_images_test.go @@ -215,5 +215,31 @@ spec: Expect(result).To(BeFalse()) }) }) + When("the CSV has empty relatedImages entries", func() { + It("should handle gracefully without panicking", func() { + csvContents := `kind: ClusterServiceVersion +apiVersion: operators.coreos.com/v1alpha1 +spec: + install: + spec: + deployments: + - spec: + template: + spec: + containers: + - image: registry.example.io/foo/bar@sha256:f000432f07cd187469f0310e3ed9dcf9a5db2be14b8bab9c5293dd1ee8518176 + name: the-operator + relatedImages: + - name: the-operator + image: registry.example.io/foo/bar@sha256:f000432f07cd187469f0310e3ed9dcf9a5db2be14b8bab9c5293dd1ee8518176 + - name: '' + image: ''` + Expect(os.WriteFile(filepath.Join(imageRef.ImageFSPath, manifestsDir, clusterServiceVersionFilename), []byte(csvContents), 0o644)).To(Succeed()) + result, err := certifiedImagesCheck.Validate(context.TODO(), imageRef) + Expect(err).ToNot(HaveOccurred()) + Expect(result).To(BeFalse()) + Expect(certifiedImagesCheck.nonCertifiedImages).To(HaveLen(1)) + }) + }) AssertMetaData(certifiedImagesCheck) })