Skip to content

Commit f850945

Browse files
IvanHuntersmyasnikovdaniil
authored andcommitted
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 <[email protected]> (cherry picked from commit 96758b9) Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 1f31dd7 commit f850945

3 files changed

Lines changed: 7 additions & 47 deletions

File tree

‎cmd/cozypkg/cmd/index.go‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ type IndexEntry struct {
3838
// OCIRef is the artifact location, e.g. oci://ghcr.io/org/repo.
3939
OCIRef string `json:"ociRef"`
4040
// Version is the OCI tag of the listed release; a version bump updates it.
41-
Version string `json:"version,omitempty"`
42-
// Digest pins the exact content the CI gate verified (sha256:<64 hex>). When
43-
// set, tapping the entry's short name pins this digest, so a short-name tap
44-
// does not follow a moved tag. The version is kept informational alongside it.
45-
Digest string `json:"digest,omitempty"`
41+
Version string `json:"version,omitempty"`
4642
Description string `json:"description,omitempty"`
4743
Homepage string `json:"homepage,omitempty"`
4844
Maintainer string `json:"maintainer,omitempty"`
@@ -92,9 +88,6 @@ func loadIndex(dir string) ([]IndexEntry, error) {
9288
if entry.Name == "" || entry.OCIRef == "" {
9389
return fmt.Errorf("%s: index entry must set both name and ociRef", rel)
9490
}
95-
if entry.Digest != "" && !ociDigestRe.MatchString(entry.Digest) {
96-
return fmt.Errorf("%s: index entry digest %q must be sha256:<64 hex>", rel, entry.Digest)
97-
}
9891
entries = append(entries, entry)
9992
return nil
10093
})
@@ -225,18 +218,13 @@ func resolveTapTarget(arg, indexRef string) (string, error) {
225218
if !ok {
226219
return "", fmt.Errorf("no index entry named %q", arg)
227220
}
228-
// Pin to the entry's recorded version and digest: the CI gate validated and
221+
// Pin to the entry's recorded version: the CI gate validated and
229222
// cosign-verified <ociRef>:<version>, so tapping must consume that exact
230-
// release rather than defaulting to latest. A recorded digest pins the exact
231-
// content (the strongest form); the version is kept informational alongside it.
232-
ref := entry.OCIRef
223+
// tag rather than defaulting to latest.
233224
if entry.Version != "" {
234-
ref += ":" + entry.Version
235-
}
236-
if entry.Digest != "" {
237-
ref += "@" + entry.Digest
225+
return entry.OCIRef + ":" + entry.Version, nil
238226
}
239-
return ref, nil
227+
return entry.OCIRef, nil
240228
}
241229

242230
func init() {

‎cmd/cozypkg/cmd/index_test.go‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,31 +124,6 @@ func TestResolveTapTarget(t *testing.T) {
124124
}
125125
}
126126

127-
func TestResolveTapTargetPinsDigest(t *testing.T) {
128-
const digest = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
129-
dir := t.TempDir()
130-
writeFile(t, dir, "pinned.yaml", "name: pin.ned\nociRef: oci://ghcr.io/foo/bar\nversion: v1.2.3\ndigest: "+digest+"\n")
131-
writeFile(t, dir, "digestonly.yaml", "name: dig.only\nociRef: oci://ghcr.io/baz/qux\ndigest: "+digest+"\n")
132-
133-
// A recorded digest pins the exact content the CI gate verified; the version
134-
// is kept informational alongside it.
135-
if got, err := resolveTapTarget("pin.ned", dir); err != nil || got != "oci://ghcr.io/foo/bar:v1.2.3@"+digest {
136-
t.Fatalf("version+digest resolve = %q err %v", got, err)
137-
}
138-
// A digest with no version resolves to the bare ref pinned by digest.
139-
if got, err := resolveTapTarget("dig.only", dir); err != nil || got != "oci://ghcr.io/baz/qux@"+digest {
140-
t.Fatalf("digest-only resolve = %q err %v", got, err)
141-
}
142-
}
143-
144-
func TestLoadIndexRejectsBadDigest(t *testing.T) {
145-
dir := t.TempDir()
146-
writeFile(t, dir, "bad.yaml", "name: x\nociRef: oci://r/x\ndigest: sha256:not-a-digest\n")
147-
if _, err := loadIndex(dir); err == nil {
148-
t.Fatal("expected error for a malformed digest in an index entry")
149-
}
150-
}
151-
152127
func TestDefaultIndexRef(t *testing.T) {
153128
if got := defaultIndexRef("/explicit"); got != "/explicit" {
154129
t.Errorf("flag should win, got %q", got)

‎hack/packages-index/README.md‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Each file under `entries/` is a single record (see `entries/example.foo.yaml`):
2020
name: foo.bar
2121
ociRef: oci://ghcr.io/foo/bar
2222
version: v1.2.3
23-
digest: sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
2423
description: A SQL database operator
2524
maintainer: Foo <[email protected]>
2625
homepage: https://example.com/foo
@@ -32,17 +31,15 @@ signing:
3231
issuer: https://token.actions.githubusercontent.com
3332
```
3433
35-
`digest` is optional but recommended: when set to the `sha256:<hex>` 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.
36-
3734
## Two-lane merge policy
3835
3936
Following krew-index, submissions take one of two lanes:
4037
41-
- **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.
38+
- **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.
4239
- **New entry, or a change to `ociRef`, `maintainer`, or `signing`.** These are the security-relevant edits and require maintainer review before merge.
4340

4441
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.
4542

4643
## Trust model
4744

48-
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.
45+
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.

0 commit comments

Comments
 (0)