From f8509450f7ca090d9873a0d1c397efcf233e7715 Mon Sep 17 00:00:00 2001 From: IvanHunters Date: Mon, 26 Oct 2026 16:55:36 +0300 Subject: [PATCH] fix(marketplace): drop the index-entry digest from the tap pin change The index-entry `digest` field, and the gate and README claims around it, assume a published index that does not exist yet: decision 0002 in the marketplace proposal defers it, and #4981 tracks that work. The gate also never compared a recorded digest against the artifact it verified, so the field added surface without the check that would make it trustworthy. Drop it from this PR. Digest pinning still works from an explicit oci://host/org/repo@sha256:... reference and from the digest a tag resolves to; only the index-entry path is removed. The tag-based pinning and the verify-flag wording stay in the index README. Assisted-by: LLM Signed-off-by: IvanHunters (cherry picked from commit 96758b9e3dbfa984a5594d63c9d8a8c63cb9f2a1) Signed-off-by: Myasnikov Daniil --- cmd/cozypkg/cmd/index.go | 22 +++++----------------- cmd/cozypkg/cmd/index_test.go | 25 ------------------------- hack/packages-index/README.md | 7 ++----- 3 files changed, 7 insertions(+), 47 deletions(-) diff --git a/cmd/cozypkg/cmd/index.go b/cmd/cozypkg/cmd/index.go index aa684ed56..c9fe82714 100644 --- a/cmd/cozypkg/cmd/index.go +++ b/cmd/cozypkg/cmd/index.go @@ -38,11 +38,7 @@ type IndexEntry struct { // OCIRef is the artifact location, e.g. oci://ghcr.io/org/repo. OCIRef string `json:"ociRef"` // Version is the OCI tag of the listed release; a version bump updates it. - Version string `json:"version,omitempty"` - // Digest pins the exact content the CI gate verified (sha256:<64 hex>). When - // set, tapping the entry's short name pins this digest, so a short-name tap - // does not follow a moved tag. The version is kept informational alongside it. - Digest string `json:"digest,omitempty"` + Version string `json:"version,omitempty"` Description string `json:"description,omitempty"` Homepage string `json:"homepage,omitempty"` Maintainer string `json:"maintainer,omitempty"` @@ -92,9 +88,6 @@ func loadIndex(dir string) ([]IndexEntry, error) { if entry.Name == "" || entry.OCIRef == "" { return fmt.Errorf("%s: index entry must set both name and ociRef", rel) } - if entry.Digest != "" && !ociDigestRe.MatchString(entry.Digest) { - return fmt.Errorf("%s: index entry digest %q must be sha256:<64 hex>", rel, entry.Digest) - } entries = append(entries, entry) return nil }) @@ -225,18 +218,13 @@ func resolveTapTarget(arg, indexRef string) (string, error) { if !ok { return "", fmt.Errorf("no index entry named %q", arg) } - // Pin to the entry's recorded version and digest: the CI gate validated and + // Pin to the entry's recorded version: the CI gate validated and // cosign-verified :, so tapping must consume that exact - // release rather than defaulting to latest. A recorded digest pins the exact - // content (the strongest form); the version is kept informational alongside it. - ref := entry.OCIRef + // tag rather than defaulting to latest. if entry.Version != "" { - ref += ":" + entry.Version + return entry.OCIRef + ":" + entry.Version, nil } - if entry.Digest != "" { - ref += "@" + entry.Digest - } - return ref, nil + return entry.OCIRef, nil } func init() { diff --git a/cmd/cozypkg/cmd/index_test.go b/cmd/cozypkg/cmd/index_test.go index 082b2d748..e43ff13d5 100644 --- a/cmd/cozypkg/cmd/index_test.go +++ b/cmd/cozypkg/cmd/index_test.go @@ -124,31 +124,6 @@ func TestResolveTapTarget(t *testing.T) { } } -func TestResolveTapTargetPinsDigest(t *testing.T) { - const digest = "sha256:1111111111111111111111111111111111111111111111111111111111111111" - dir := t.TempDir() - writeFile(t, dir, "pinned.yaml", "name: pin.ned\nociRef: oci://ghcr.io/foo/bar\nversion: v1.2.3\ndigest: "+digest+"\n") - writeFile(t, dir, "digestonly.yaml", "name: dig.only\nociRef: oci://ghcr.io/baz/qux\ndigest: "+digest+"\n") - - // A recorded digest pins the exact content the CI gate verified; the version - // is kept informational alongside it. - if got, err := resolveTapTarget("pin.ned", dir); err != nil || got != "oci://ghcr.io/foo/bar:v1.2.3@"+digest { - t.Fatalf("version+digest resolve = %q err %v", got, err) - } - // A digest with no version resolves to the bare ref pinned by digest. - if got, err := resolveTapTarget("dig.only", dir); err != nil || got != "oci://ghcr.io/baz/qux@"+digest { - t.Fatalf("digest-only resolve = %q err %v", got, err) - } -} - -func TestLoadIndexRejectsBadDigest(t *testing.T) { - dir := t.TempDir() - writeFile(t, dir, "bad.yaml", "name: x\nociRef: oci://r/x\ndigest: sha256:not-a-digest\n") - if _, err := loadIndex(dir); err == nil { - t.Fatal("expected error for a malformed digest in an index entry") - } -} - func TestDefaultIndexRef(t *testing.T) { if got := defaultIndexRef("/explicit"); got != "/explicit" { t.Errorf("flag should win, got %q", got) diff --git a/hack/packages-index/README.md b/hack/packages-index/README.md index 52cbc1205..1f0195ea1 100644 --- a/hack/packages-index/README.md +++ b/hack/packages-index/README.md @@ -20,7 +20,6 @@ Each file under `entries/` is a single record (see `entries/example.foo.yaml`): name: foo.bar ociRef: oci://ghcr.io/foo/bar version: v1.2.3 -digest: sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef description: A SQL database operator maintainer: Foo homepage: https://example.com/foo @@ -32,17 +31,15 @@ signing: issuer: https://token.actions.githubusercontent.com ``` -`digest` is optional but recommended: when set to the `sha256:` the gate verified, tapping the entry's short name pins that exact content instead of following the `version` tag, so a later retag of the same version cannot change what installs. The gate records it from the artifact it just verified, and `version` is kept informational alongside it. - ## Two-lane merge policy Following krew-index, submissions take one of two lanes: -- **Owner version bump.** A change that only updates an existing entry's `version`, `digest`, or description, leaving `ociRef` and `signing` untouched, auto-merges once the new artifact validates and is signed by the entry's **recorded** cosign identity. This keeps the routine "new release of a listed package" path fast. +- **Owner version bump.** A change that only updates an existing entry's `version` or description, leaving `ociRef` and `signing` untouched, auto-merges once the new artifact validates and is signed by the entry's **recorded** cosign identity. This keeps the routine "new release of a listed package" path fast. - **New entry, or a change to `ociRef`, `maintainer`, or `signing`.** These are the security-relevant edits and require maintainer review before merge. Cosign verification is **mandatory** on the gate for both lanes: the trust anchor is the recorded signing identity, so a bump fails if the new artifact is not signed by the originally approved identity. ## Trust model -Signature verification happens here, at publication time, not at tap time. `cozypkg tap` and the dashboard connect flow validate an artifact's structure; they do not verify a cosign signature unless asked (with `--certificate-identity` / `--certificate-oidc-issuer`, which set a Flux pull-time verify policy). A cluster that taps a listed repository otherwise trusts that this index already verified it. The verification point is this CI gate, which pins each release to the entry's recorded identity. Independently of signing, a tapped repository is pinned to a digest and does not follow a moved tag: a `digest` recorded on the entry pins the exact content the gate verified, and a tag-only tap is pinned to the digest it first resolves to. Installing an app from a tapped repository runs its charts in the management cluster, so operators should tap only sources they trust or that appear in a curated index like this one. +Signature verification happens here, at publication time, not at tap time. `cozypkg tap` and the dashboard connect flow validate an artifact's structure; they do not verify a cosign signature unless asked (with `--certificate-identity` / `--certificate-oidc-issuer`, which set a Flux pull-time verify policy). A cluster that taps a listed repository otherwise trusts that this index already verified it. The verification point is this CI gate, which pins each release to the entry's recorded identity. Independently of signing, a tapped repository is pinned to a digest and does not follow a moved tag: a tag-only tap is pinned to the digest it first resolves to. Installing an app from a tapped repository runs its charts in the management cluster, so operators should tap only sources they trust or that appear in a curated index like this one.