diff --git a/cmd/cozypkg/cmd/tap.go b/cmd/cozypkg/cmd/tap.go index 96e3bb9cc..c41a655e3 100644 --- a/cmd/cozypkg/cmd/tap.go +++ b/cmd/cozypkg/cmd/tap.go @@ -306,11 +306,18 @@ With --secret the OCIRepository is given a pull-credential secretRef (the admin pre-creates the Secret in cozy-system), so a private repository taps in one command. -Trust: tap validates the artifact's structure but does NOT verify its cosign -signature. Signature verification is the community index's job at publication -time ('cozypkg validate --require-signature' in the index CI gate, pinned to -the entry's recorded identity), and can additionally be enforced at pull time -via Flux OCIRepository verification. Installing an app from a tapped repository +Pinning: a tapped repository does not follow a moving tag. A reference given by +digest (oci://host/org/repo@sha256:...) is pinned to that digest immediately; a +tag reference is pinned to the digest it currently resolves to as soon as the +source materializes, with the tag kept informational. Moving the tag upstream +changes nothing in the cluster; tap the repository again to move the pin. + +Trust: tap validates the artifact's structure. Keyless signature verification at +pull time is enabled with --certificate-identity and --certificate-oidc-issuer, +which set a Flux cosign verify policy on the source so content is pulled only +when signed by that identity. Signature verification at publication time is the +community index's job ('cozypkg validate --require-signature' in the index CI +gate, pinned to the entry's recorded identity). Installing an app from a tapped repository runs its charts in your management cluster: tap only sources you trust.`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/hack/packages-index/README.md b/hack/packages-index/README.md index 7de796195..52cbc1205 100644 --- a/hack/packages-index/README.md +++ b/hack/packages-index/README.md @@ -20,6 +20,7 @@ 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 @@ -31,15 +32,17 @@ 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` 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`, `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. - **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 but do not verify its cosign signature: a cluster that taps a listed repository trusts that this index already verified it. The verification points are this CI gate (which pins each release to the entry's recorded identity) and, optionally, Flux `OCIRepository` verification at pull time. 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 `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. diff --git a/pkg/apis/core/v1alpha1/model_name.go b/pkg/apis/core/v1alpha1/model_name.go index 1fca4d7d6..3ba6d8f36 100644 --- a/pkg/apis/core/v1alpha1/model_name.go +++ b/pkg/apis/core/v1alpha1/model_name.go @@ -118,3 +118,7 @@ func (in TapSource) OpenAPIModelName() string { func (in TapPackage) OpenAPIModelName() string { return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.TapPackage" } + +func (in TapVerify) OpenAPIModelName() string { + return "com.github.cozystack.cozystack.pkg.apis.core.v1alpha1.TapVerify" +} diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 1edff5230..e34c63d72 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -48,6 +48,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA corev1alpha1.TapPackage{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapPackage(ref), corev1alpha1.TapSource{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapSource(ref), corev1alpha1.TapSpec{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapSpec(ref), + corev1alpha1.TapVerify{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TapVerify(ref), corev1alpha1.TenantModule{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModule(ref), corev1alpha1.TenantModuleList{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModuleList(ref), corev1alpha1.TenantModuleStatus{}.OpenAPIModelName(): schema_pkg_apis_core_v1alpha1_TenantModuleStatus(ref), @@ -715,11 +716,51 @@ func schema_pkg_apis_core_v1alpha1_TapSpec(ref common.ReferenceCallback) common. Format: "", }, }, + "verify": { + SchemaProps: spec.SchemaProps{ + Description: "Verify is a connect-time input only: a signature-verification policy to set on the tap's Flux source (spec.verify). It is consumed when a Tap is created, preserved across repeat connects, and never returned on read.", + Ref: ref(corev1alpha1.TapVerify{}.OpenAPIModelName()), + }, + }, }, }, }, Dependencies: []string{ - corev1alpha1.TapPackage{}.OpenAPIModelName(), corev1alpha1.TapSource{}.OpenAPIModelName()}, + corev1alpha1.TapPackage{}.OpenAPIModelName(), corev1alpha1.TapSource{}.OpenAPIModelName(), corev1alpha1.TapVerify{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_core_v1alpha1_TapVerify(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TapVerify is a connect-time signature-verification policy for a tap. It maps to the Flux OCIRepository spec.verify: keyless cosign identity matching (issuer + subject) is the supported form, so a moved tag cannot be followed unless it is also signed by the recorded identity.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "provider": { + SchemaProps: spec.SchemaProps{ + Description: "Provider is the signature technology: \"cosign\" (default) or \"notation\".", + Type: []string{"string"}, + Format: "", + }, + }, + "issuer": { + SchemaProps: spec.SchemaProps{ + Description: "Issuer is the OIDC issuer URL for keyless cosign verification, e.g. https://token.actions.githubusercontent.com.", + Type: []string{"string"}, + Format: "", + }, + }, + "subject": { + SchemaProps: spec.SchemaProps{ + Description: "Subject is the certificate identity (subject) for keyless cosign verification; it is matched against the artifact's signing identity.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, } }