Skip to content

Commit 10be3d2

Browse files
committed
fix(marketplace): reject a non-cosign verify provider at connect
TapVerify advertised provider notation, but buildVerifySpec always emits a matchOIDCIdentity block, which is meaningful only for keyless cosign. Setting provider: notation produced a nonsensical verify block. The connect now rejects any provider other than cosign and the type doc no longer advertises notation, since only keyless cosign identity matching is settable here. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
1 parent 0fd9703 commit 10be3d2

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

‎pkg/apis/core/v1alpha1/tap_types.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ type TapSpec struct {
6363
// (issuer + subject) is the supported form, so a moved tag cannot be followed
6464
// unless it is also signed by the recorded identity.
6565
type TapVerify struct {
66-
// Provider is the signature technology: "cosign" (default) or "notation".
66+
// Provider is the signature technology. Only keyless cosign (the default) is
67+
// settable at connect, since the identity match below is a cosign construct;
68+
// a non-cosign value is rejected.
6769
Provider string `json:"provider,omitempty"`
6870
// Issuer is the OIDC issuer URL for keyless cosign verification, e.g.
6971
// https://token.actions.githubusercontent.com.

‎pkg/generated/openapi/zz_generated.openapi.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/registry/core/tap/compute.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,16 @@ func parseConnectURL(url, tagOverride string) (connectTarget, error) {
9393
// signer would be worse than none. A key-based policy an admin sets by hand on
9494
// the source is preserved across connects (see Create) but is not settable here.
9595
func buildVerifySpec(v *corev1alpha1.TapVerify) (map[string]any, error) {
96+
// Only keyless cosign is settable here; matchOIDCIdentity is a cosign-only
97+
// construct, so a non-cosign provider would produce a nonsensical policy.
98+
if v.Provider != "" && v.Provider != "cosign" {
99+
return nil, fmt.Errorf("verify.provider %q is not supported; only keyless cosign identity matching is settable at connect", v.Provider)
100+
}
96101
if v.Issuer == "" || v.Subject == "" {
97102
return nil, fmt.Errorf("verify requires both issuer and subject (keyless cosign identity)")
98103
}
99-
provider := v.Provider
100-
if provider == "" {
101-
provider = "cosign"
102-
}
103104
return map[string]any{
104-
"provider": provider,
105+
"provider": "cosign",
105106
"matchOIDCIdentity": []any{map[string]any{"issuer": v.Issuer, "subject": v.Subject}},
106107
}, nil
107108
}

‎pkg/registry/core/tap/rest_test.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,21 @@ func TestCreateVerifyRequiresBothIdentityFields(t *testing.T) {
416416
}
417417
}
418418

419+
func TestCreateVerifyRejectsNonCosignProvider(t *testing.T) {
420+
r := fakeREST()
421+
in := &corev1alpha1.Tap{Spec: corev1alpha1.TapSpec{
422+
URL: "oci://ghcr.io/foo/bar:v1",
423+
Verify: &corev1alpha1.TapVerify{
424+
Provider: "notation",
425+
Issuer: "https://token.actions.githubusercontent.com",
426+
Subject: "https://github.com/org/repo/.github/workflows/release.yml@refs/tags/v1",
427+
},
428+
}}
429+
if _, err := r.Create(context.Background(), in, nil, nil); !apierrors.IsBadRequest(err) {
430+
t.Errorf("a non-cosign provider must be BadRequest (matchOIDCIdentity is cosign-only), got %v", err)
431+
}
432+
}
433+
419434
func TestCreateRefusesConflictingURL(t *testing.T) {
420435
// A source with the same derived name but a different registry host must not
421436
// be silently retargeted.

0 commit comments

Comments
 (0)