Exit with error if no matching predicate type exists

Signed-off-by: Fredrik Skogman <kommendorkapten@github.com>
This commit is contained in:
Fredrik Skogman 2025-02-11 09:07:51 +01:00
parent 55579582e2
commit bf3a40aef3
No known key found for this signature in database
2 changed files with 13 additions and 1 deletions

View file

@ -236,7 +236,7 @@ func runVerify(opts *Options) error {
filteredAttestations := verification.FilterAttestations(ec.PredicateType, attestations)
if len(filteredAttestations) == 0 {
opts.Logger.Printf(opts.Logger.ColorScheme.Red("✗ No attestations found with predicate type: %s\n"), opts.PredicateType)
return err
return fmt.Errorf("no matching predicate found")
}
attestations = filteredAttestations

View file

@ -501,6 +501,18 @@ func TestRunVerify(t *testing.T) {
require.Nil(t, runVerify(&customOpts))
})
t.Run("with valid OCI artifact with UseBundleFromRegistry flag and unknown predicate type", func(t *testing.T) {
customOpts := publicGoodOpts
customOpts.ArtifactPath = "oci://ghcr.io/github/test"
customOpts.BundlePath = ""
customOpts.UseBundleFromRegistry = true
customOpts.PredicateType = "https://predicate.type"
err := runVerify(&customOpts)
require.Error(t, err)
require.ErrorContains(t, err, "no matching predicate found")
})
t.Run("with valid OCI artifact with UseBundleFromRegistry flag but no bundle return from registry", func(t *testing.T) {
customOpts := publicGoodOpts
customOpts.ArtifactPath = "oci://ghcr.io/github/test"