From e96313429971443df0f2d852fb36939db74c747f Mon Sep 17 00:00:00 2001 From: Michal Matloka Date: Fri, 13 Nov 2026 22:19:04 +0100 Subject: [PATCH 1/2] fix(security): Go 1.26.11, Secret opt-in and tenancy hardening - Bump the Go minimum to 1.26.11 and update all dependencies. - Run the quickstart, scenario and webhook manifests as non-root with dropped capabilities. - Tenancy: empty prefixes fail closed; Schema Registry subjects are checked against tenancy prefixes. - Finalizers only clean up specs the operator applied and the namespace is still allowed to manage. - Cluster ACL view: Allow/Deny conflicts resolve to Deny, and prune scope covers every policy. - BREAKING: referenced Secrets must carry the label gitops.monedula.dev/credential-source=true (opt out with --require-secret-label=false / requireSecretLabel: false). - Optional --secret-namespaces / rbac.secretNamespaces replaces cluster-wide Secret RBAC with per-namespace Roles. --- CHANGELOG.md | 38 +++ README.md | 3 +- .../templates/clusterrole.yaml | 2 + .../monedula-gitops/templates/deployment.yaml | 6 + .../templates/secret-roles.yaml | 42 +++ charts/monedula-gitops/values.yaml | 15 + .../webhook/manager_webhook_patch.yaml | 13 + config/manager/manager.yaml | 3 + go.mod | 144 +++++---- go.sum | 302 +++++++++--------- internal/cli/operator.go | 7 + internal/matrix/versions.yaml | 10 +- .../controller/deletion_coownership_test.go | 5 + .../controller/duplicate_envtest_test.go | 2 +- .../controller/duplicate_recheck_test.go | 1 + .../operator/controller/duplicate_test.go | 1 + .../controller/finalizer_authz_test.go | 159 +++++++++ .../kafkaaccesspolicy_controller.go | 22 ++ .../kafkaaccesspolicy_controller_test.go | 1 + .../controller/kafkacluster_controller.go | 13 +- .../controller/kafkaquota_controller.go | 39 +++ .../kafkatopic_cleanup_authz_test.go | 164 ++++++++++ .../controller/kafkatopic_controller.go | 81 +++++ .../controller/kafkatopic_controller_test.go | 20 ++ .../controller/kafkatopic_finalizer_test.go | 3 + .../kafkatopic_finalizer_verify_test.go | 3 + .../controller/kafkauser_controller.go | 46 +++ .../controller/kafkauser_envtest_test.go | 6 +- .../operator/controller/rest_factory_test.go | 2 +- internal/operator/controller/secret.go | 17 +- .../controller/substrate_locking_test.go | 1 + internal/operator/k8sresolver.go | 12 +- internal/operator/k8sresolver_test.go | 4 +- internal/operator/manager/manager.go | 30 +- internal/operator/manager/render_test.go | 26 ++ internal/operator/reconcile/aclview_test.go | 32 ++ internal/operator/reconcile/reconcile.go | 113 +++++-- internal/operator/reconcile/user.go | 17 + internal/operator/reconcile/user_test.go | 29 +- internal/operator/secretpolicy.go | 86 +++++ internal/operator/secretpolicy_test.go | 63 ++++ internal/tenancy/tenancy.go | 39 ++- internal/tenancy/tenancy_test.go | 35 ++ internal/validation/validation.go | 7 + internal/validation/validation_test.go | 11 + quickstart/k8s/kafka/kafka.yaml | 26 ++ quickstart/k8s/kafka/schema-registry.yaml | 18 ++ .../operator/kafka-credentials.secret.yaml | 2 + .../clusters/auth-mtls/compose.apache.yaml | 2 +- .../clusters/auth-oauth/compose.apache.yaml | 2 +- .../auth-sasl-ssl/compose.apache.yaml | 4 +- .../auth-sasl-ssl/k8s/kafka-tls-secret.yaml | 2 + .../clusters/auth-sasl-ssl/k8s/kafka.yaml | 31 ++ .../clusters/shared-sasl/compose.apache.yaml | 4 +- scenarios/clusters/shared-sasl/k8s/kafka.yaml | 26 ++ .../shared-sasl/k8s/schema-registry.yaml | 18 ++ test/e2e/k8s/lib.bash | 8 + test/e2e/k8s/setup.sh | 6 + 58 files changed, 1535 insertions(+), 289 deletions(-) create mode 100644 charts/monedula-gitops/templates/secret-roles.yaml create mode 100644 internal/operator/controller/finalizer_authz_test.go create mode 100644 internal/operator/controller/kafkatopic_cleanup_authz_test.go create mode 100644 internal/operator/secretpolicy.go create mode 100644 internal/operator/secretpolicy_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index f29c4e3..ff95e71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- **Namespaced Secret RBAC:** new operator flag `--secret-namespaces` and chart value + `rbac.secretNamespaces`. When set, the chart drops Secret access from the ClusterRole and grants it + through a Role + RoleBinding in each listed namespace only; the operator scopes its Secret watch to + those namespaces and refuses Secret references outside them. Empty (default) keeps cluster-wide + Secret access. - **Import a part of a cluster:** `import cluster` takes repeatable `--topic ` and `--exclude-topic ` flags (`path.Match` syntax, as in `spec.tenancy`). Only matching topics are imported, together with the ACLs and MDS role bindings on them, their Schema Registry @@ -37,6 +42,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 rejected, and an `import` round-trip. It runs in a new `cp-8.3-link` e2e matrix cell. ### Changed +- **BREAKING — Secrets must opt in (security):** the operator now only uses a referenced Secret + (KafkaCluster credentials and TLS material, KafkaTopic schema bodies, KafkaUser passwords) if it + is labelled `gitops.monedula.dev/credential-source=true`. Before, anyone who could create one of + these resources could make the operator read any Secret in the namespace and send it to an + endpoint they chose, even without RBAC to read that Secret themselves. Only someone who can write + a Secret can label it. **Upgrade:** label every Secret your resources reference + (`kubectl label secret gitops.monedula.dev/credential-source=true`), or keep the old + behaviour with `--require-secret-label=false` (chart: `requireSecretLabel: false`). Unlabelled + references fail with an error naming the Secret and the label; a KafkaUser reports + `SecretNotLabeled`, and a KafkaCluster's `CredentialSourceUnwatched` condition lists them. +- Go 1.26.11 minimum (`go.mod`); all Go dependencies updated to their latest releases that support it. - **Operator, `KafkaTopic` finalizer:** the `gitops.monedula.dev/force-finalizer-removal` annotation now always orphans: the finalizer is removed with no topic, ACL or schema cleanup, even when the cluster is reachable and `gitops.monedula.dev/allow-delete` is set. @@ -53,8 +69,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Mirror guard (CLI and operator):** for a live or stopping mirror topic, or one whose mirror state is unknown, ACL prune (`DeleteAcl`) on the literal topic resource is now suppressed as well as ACL creation. Prefixed and wildcard ACLs are unaffected. +- **Validated versions:** CI now also runs against Apache Kafka 4.4 (`apache/kafka:4.4.0`, new + `ak-4.4` cell). It takes over from 4.3 as the Apache cell paired with Confluent Schema Registry + and run in the end-to-end scenario suite; Apache Kafka 4.3 stays in the adapter integration + tests. The `compose.apache.yaml` overlays default to `apache/kafka:4.4.0`. ### Fixed +- **Security — tenancy:** an empty-string `spec.tenancy.topicPrefixes[].prefixes` entry is now + rejected by validation and ignored by enforcement; previously it matched every name and lifted the + namespace's prefix restriction. A namespace matched by a rule stays restricted even if no usable + prefix is left. +- **Security — Schema Registry subjects:** subjects a `KafkaTopic` manages (Custom and RecordName + strategies name them independently of the topic) are now checked against the namespace's + tenancy prefixes on reconcile and before finalizer deletion (`TenancyDenied`). +- **Security — finalizers:** the `KafkaTopic`, `KafkaAccessPolicy`, `KafkaQuota` and `KafkaUser` + finalizers only run destructive cleanup for a spec the operator applied (current generation + reconciled, not refused by validation or tenancy) and that the current tenancy policy still + allows. Otherwise they leave broker state in place and emit a `CleanupSkipped` event. This closes + edits to a terminating CR redirecting cleanup, and refused CRs deleting state they never managed. +- **Security — ACL conflicts:** a cross-resource Allow/Deny conflict on one ACL tuple now resolves + to the Deny, and every owner's `spec.prune` consent (including the conflict loser's) takes part + in the prune veto, so an Allow policy can no longer override or prune another resource's Deny. +- **Security — non-root manifests:** the quickstart and scenario Kafka / Schema Registry workloads + and the webhook patch run as non-root with a pinned UID, `RuntimeDefault` seccomp, no privilege + escalation and all capabilities dropped; the operator pins UID/GID 65532. - **CLI, `KafkaMirrorTopic` apply:** a mirror create that Kafka REST rejects with a 4xx (for example a missing source topic, 404) is reported as `rejected by Kafka REST ()` instead of "outcome unknown, re-run diff before retrying". diff --git a/README.md b/README.md index 25f61e3..7cd947c 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,8 @@ CI runs the adapter integration tests against every cell below on each pull requ |---|---|---|---|---| | `ak-3.9` | `apache/kafka:3.9.2` | `—` | integration | topics, acls, quotas, scram | | `ak-4.0` | `apache/kafka:4.0.2` | `—` | integration | topics, acls, quotas, scram | -| `ak-4.3` | `apache/kafka:4.3.1` | `confluentinc/cp-schema-registry:8.3.1` | integration, e2e | topics, acls, quotas, scram, schemaregistry | +| `ak-4.3` | `apache/kafka:4.3.1` | `—` | integration | topics, acls, quotas, scram | +| `ak-4.4` | `apache/kafka:4.4.0` | `confluentinc/cp-schema-registry:8.3.1` | integration, e2e | topics, acls, quotas, scram, schemaregistry | | `cp-7.6` | `confluentinc/cp-kafka:7.6.13` | `confluentinc/cp-schema-registry:7.6.13` | integration | topics, acls, quotas, scram, schemaregistry | | `cp-7.9` | `confluentinc/cp-kafka:7.9.9` | `confluentinc/cp-schema-registry:7.9.9` | integration, e2e | topics, acls, quotas, scram, schemaregistry | | `cp-8.0` | `confluentinc/cp-kafka:8.0.7` | `confluentinc/cp-schema-registry:8.0.7` | integration | topics, acls, quotas, scram, schemaregistry | diff --git a/charts/monedula-gitops/templates/clusterrole.yaml b/charts/monedula-gitops/templates/clusterrole.yaml index a1e3a0b..e831f0f 100644 --- a/charts/monedula-gitops/templates/clusterrole.yaml +++ b/charts/monedula-gitops/templates/clusterrole.yaml @@ -15,6 +15,7 @@ rules: - get - list - watch +{{- if not .Values.rbac.secretNamespaces }} - apiGroups: - "" resources: @@ -25,6 +26,7 @@ rules: - list - update - watch +{{- end }} - apiGroups: - authentication.k8s.io resources: diff --git a/charts/monedula-gitops/templates/deployment.yaml b/charts/monedula-gitops/templates/deployment.yaml index da23c72..136c35f 100644 --- a/charts/monedula-gitops/templates/deployment.yaml +++ b/charts/monedula-gitops/templates/deployment.yaml @@ -54,6 +54,12 @@ spec: {{- with .Values.clusterNamespace }} - --cluster-namespace={{ . }} {{- end }} + {{- with .Values.rbac.secretNamespaces }} + - --secret-namespaces={{ join "," . }} + {{- end }} + {{- if not .Values.requireSecretLabel }} + - --require-secret-label=false + {{- end }} {{- with .Values.resyncInterval }} - --resync-interval={{ . }} {{- end }} diff --git a/charts/monedula-gitops/templates/secret-roles.yaml b/charts/monedula-gitops/templates/secret-roles.yaml new file mode 100644 index 0000000..88c1111 --- /dev/null +++ b/charts/monedula-gitops/templates/secret-roles.yaml @@ -0,0 +1,42 @@ +{{- /* Namespaced Secret access (rbac.secretNamespaces): replaces the ClusterRole's + cluster-wide Secret rule with a Role + RoleBinding per listed namespace. Verbs + mirror the ClusterRole's Secret rule (config/rbac/role.yaml). */ -}} +{{- if .Values.rbac.create }} +{{- range .Values.rbac.secretNamespaces }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "monedula-gitops.fullname" $ }}-secrets + namespace: {{ . }} + labels: + {{- include "monedula-gitops.labels" $ | nindent 4 }} +rules: +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - get + - list + - update + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "monedula-gitops.fullname" $ }}-secrets + namespace: {{ . }} + labels: + {{- include "monedula-gitops.labels" $ | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "monedula-gitops.fullname" $ }}-secrets +subjects: +- kind: ServiceAccount + name: {{ include "monedula-gitops.serviceAccountName" $ }} + namespace: {{ $.Release.Namespace }} +{{- end }} +{{- end }} diff --git a/charts/monedula-gitops/values.yaml b/charts/monedula-gitops/values.yaml index 7ae22a8..a37b1ee 100644 --- a/charts/monedula-gitops/values.yaml +++ b/charts/monedula-gitops/values.yaml @@ -28,6 +28,18 @@ serviceAccount: rbac: create: true + # Namespaces the operator may read, write and watch Secrets in (--secret-namespaces). + # Empty (default): Secret access is granted cluster-wide in the ClusterRole. Non-empty: the + # ClusterRole carries NO Secret rule; a Role + RoleBinding is rendered in each listed namespace + # instead, and the operator refuses Secret references outside them. List every namespace whose + # KafkaCluster / KafkaTopic / KafkaUser resources reference Secrets (with clusterNamespace set, + # that is the cluster namespace plus the namespaces of topics and users that reference Secrets). + secretNamespaces: [] + +# Use only Secrets labelled gitops.monedula.dev/credential-source=true (--require-secret-label). +# Keep this on: without it, anyone who can create a KafkaCluster, KafkaTopic or KafkaUser can make +# the operator read any Secret in that namespace and send it to an endpoint they choose. +requireSecretLabel: true crds: enabled: true # render CRDs into templates/ @@ -67,6 +79,9 @@ podAnnotations: {} podLabels: {} podSecurityContext: runAsNonRoot: true + # distroless "nonroot" user; pinned so the kubelet can verify non-root. + runAsUser: 65532 + runAsGroup: 65532 seccompProfile: type: RuntimeDefault securityContext: diff --git a/config/components/webhook/manager_webhook_patch.yaml b/config/components/webhook/manager_webhook_patch.yaml index 24a8a67..ea2c508 100644 --- a/config/components/webhook/manager_webhook_patch.yaml +++ b/config/components/webhook/manager_webhook_patch.yaml @@ -6,8 +6,21 @@ metadata: spec: template: spec: + # Restated from config/manager so this patch is non-root on its own too. + securityContext: + runAsNonRoot: true + runAsUser: 65532 + runAsGroup: 65532 + seccompProfile: + type: RuntimeDefault containers: - name: manager + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL args: - operator - --metrics-bind-address=:8080 diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 9d2cdef..bc07d76 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -28,6 +28,9 @@ spec: serviceAccountName: monedula-manager securityContext: runAsNonRoot: true + # distroless "nonroot" user; pinned so the kubelet can verify non-root. + runAsUser: 65532 + runAsGroup: 65532 seccompProfile: type: RuntimeDefault containers: diff --git a/go.mod b/go.mod index a6599d6..d3eb2c7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/monedula-dev/monedula-gitops -go 1.26.0 +go 1.26.11 require ( github.com/go-logr/logr v1.4.4 @@ -10,25 +10,25 @@ require ( github.com/stretchr/testify v1.12.1 github.com/testcontainers/testcontainers-go v0.45.0 github.com/testcontainers/testcontainers-go/modules/kafka v0.45.0 - github.com/twmb/franz-go v1.22.2 - github.com/twmb/franz-go/pkg/kadm v1.19.0 + github.com/twmb/franz-go v1.22.3 + github.com/twmb/franz-go/pkg/kadm v1.20.0 github.com/twmb/franz-go/pkg/kmsg v1.15.1 golang.org/x/oauth2 v0.38.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.37.2 k8s.io/apimachinery v0.37.2 k8s.io/client-go v0.37.2 - k8s.io/utils v0.0.0-20260626114624-be93311217bd + k8s.io/utils v0.0.0-20261023123148-ca04ba58ecab sigs.k8s.io/controller-runtime v0.25.2 sigs.k8s.io/controller-tools v0.23.0 sigs.k8s.io/yaml v1.6.0 ) require ( - cel.dev/expr v0.25.2 // indirect + cel.dev/expr v0.26.0 // indirect dario.cat/mergo v1.0.2 // indirect - github.com/Azure/go-ansiterm v0.0.0-20261006220739-8c912ac31dd4 // indirect - github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/Azure/go-ansiterm v0.0.0-20261013165250-51075c6ea6bc // indirect + github.com/Microsoft/go-winio v0.6.4 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect @@ -37,115 +37,117 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect - github.com/containerd/log v0.1.0 // indirect + github.com/containerd/log v0.2.0 // indirect github.com/containerd/platforms v0.2.1 // indirect github.com/cpuguy83/dockercfg v0.3.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/go-connections v0.8.2 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/ebitengine/purego v0.10.1 // indirect + github.com/ebitengine/purego v0.11.3 // indirect github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/evanphx/json-patch/v5 v5.9.11 // indirect github.com/fatih/color v1.19.0 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect - github.com/fsnotify/fsnotify v1.10.0 // indirect - github.com/fxamacker/cbor/v2 v2.9.1 // indirect + github.com/fsnotify/fsnotify v1.10.1 // indirect + github.com/fxamacker/cbor/v2 v2.10.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-openapi/jsonpointer v1.0.0 // indirect - github.com/go-openapi/jsonreference v1.0.0 // indirect - github.com/go-openapi/swag v0.28.0 // indirect - github.com/go-openapi/swag/cmdutils v0.28.0 // indirect - github.com/go-openapi/swag/conv v0.28.0 // indirect - github.com/go-openapi/swag/fileutils v0.28.0 // indirect - github.com/go-openapi/swag/jsonutils v0.28.0 // indirect - github.com/go-openapi/swag/loading v0.28.0 // indirect - github.com/go-openapi/swag/mangling v0.28.0 // indirect - github.com/go-openapi/swag/netutils v0.28.0 // indirect - github.com/go-openapi/swag/pools v0.28.0 // indirect - github.com/go-openapi/swag/stringutils v0.28.0 // indirect - github.com/go-openapi/swag/typeutils v0.28.0 // indirect - github.com/go-openapi/swag/yamlutils v0.28.0 // indirect + github.com/go-openapi/jsonpointer v1.0.2 // indirect + github.com/go-openapi/jsonreference v1.0.3 // indirect + github.com/go-openapi/swag v0.29.2 // indirect + github.com/go-openapi/swag/cmdutils v0.29.2 // indirect + github.com/go-openapi/swag/conv v0.29.2 // indirect + github.com/go-openapi/swag/fileutils v0.29.2 // indirect + github.com/go-openapi/swag/jsonutils v0.29.2 // indirect + github.com/go-openapi/swag/loading v0.29.2 // indirect + github.com/go-openapi/swag/mangling v0.29.2 // indirect + github.com/go-openapi/swag/netutils v0.29.2 // indirect + github.com/go-openapi/swag/pools v0.29.2 // indirect + github.com/go-openapi/swag/stringutils v0.29.2 // indirect + github.com/go-openapi/swag/typeutils v0.29.2 // indirect + github.com/go-openapi/swag/yamlutils v0.29.2 // indirect github.com/gobuffalo/flect v1.0.3 // indirect - github.com/google/cel-go v0.29.2 // indirect + github.com/google/cel-go v0.31.0 // indirect github.com/google/gnostic-models v0.7.1 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.33.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.20.3 // indirect + github.com/klauspost/compress v1.20.4 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirect - github.com/magiconair/properties v1.18.12 // indirect + github.com/lufia/plan9stats v0.0.0-20261101121723-be84dd9509a0 // indirect + github.com/magiconair/properties v1.18.13 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mdelapenya/tlscert v0.2.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/go-archive v0.3.3 // indirect - github.com/moby/moby/api v1.56.1 // indirect - github.com/moby/moby/client v0.6.2 // indirect + github.com/moby/moby/api v1.57.0 // indirect + github.com/moby/moby/client v0.6.3 // indirect github.com/moby/patternmatcher v0.6.1 // indirect github.com/moby/sys/sequential v0.7.0 // indirect - github.com/moby/sys/user v0.4.1 // indirect - github.com/moby/sys/userns v0.1.0 // indirect + github.com/moby/sys/user v0.5.0 // indirect + github.com/moby/sys/userns v0.2.1 // indirect github.com/moby/term v0.5.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect + github.com/pandatix/go-abnf v0.5.5 // indirect github.com/pierrec/lz4/v4 v4.1.33 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect - github.com/prometheus/common v0.72.0 // indirect - github.com/prometheus/procfs v0.22.0 // indirect - github.com/shirou/gopsutil/v4 v4.26.6 // indirect - github.com/sirupsen/logrus v1.9.4 // indirect - github.com/spf13/pflag v1.0.10 // indirect + github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 // indirect + github.com/prometheus/common v0.74.0 // indirect + github.com/prometheus/procfs v0.23.0 // indirect + github.com/shirou/gopsutil/v4 v4.26.10 // indirect + github.com/sirupsen/logrus v1.10.2 // indirect + github.com/spf13/pflag v1.1.0 // indirect github.com/tklauser/go-sysconf v0.4.0 // indirect github.com/tklauser/numcpus v0.12.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 // indirect - go.opentelemetry.io/otel v1.46.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0 // indirect - go.opentelemetry.io/otel/metric v1.46.0 // indirect - go.opentelemetry.io/otel/sdk v1.46.0 // indirect - go.opentelemetry.io/otel/trace v1.46.0 // indirect - go.opentelemetry.io/proto/otlp v1.11.0 // indirect - go.yaml.in/yaml/v2 v2.4.4 // indirect - go.yaml.in/yaml/v3 v3.0.5 // indirect - golang.org/x/crypto v0.58.0 // indirect - golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect - golang.org/x/mod v0.41.0 // indirect - golang.org/x/net v0.60.0 // indirect - golang.org/x/sync v0.24.0 // indirect - golang.org/x/sys v0.49.0 // indirect - golang.org/x/term v0.47.0 // indirect - golang.org/x/text v0.43.0 // indirect - golang.org/x/time v0.15.0 // indirect - golang.org/x/tools v0.51.0 // indirect - gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect - google.golang.org/grpc v1.83.2 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.47.0 // indirect + go.opentelemetry.io/otel/log v1.47.0 // indirect + go.opentelemetry.io/otel/metric v1.47.0 // indirect + go.opentelemetry.io/otel/sdk v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect + go.opentelemetry.io/proto/otlp v1.11.1 // indirect + go.yaml.in/yaml/v2 v2.4.5 // indirect + go.yaml.in/yaml/v3 v3.0.6 // indirect + golang.org/x/crypto v0.59.0 // indirect + golang.org/x/exp v0.0.0-20261113113407-e3970619a1a4 // indirect + golang.org/x/mod v0.43.0 // indirect + golang.org/x/net v0.62.0 // indirect + golang.org/x/sync v0.25.0 // indirect + golang.org/x/sys v0.50.0 // indirect + golang.org/x/term v0.48.0 // indirect + golang.org/x/text v0.44.0 // indirect + golang.org/x/time v0.16.0 // indirect + golang.org/x/tools v0.52.1-0.20261106145633-d407941a339a // indirect + gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20261110000943-09e21b237f2c // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c // indirect + google.golang.org/grpc v1.85.0 // indirect google.golang.org/protobuf v1.36.12 // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - k8s.io/apiextensions-apiserver v0.37.0 // indirect - k8s.io/apiserver v0.37.0 // indirect - k8s.io/code-generator v0.37.0 // indirect - k8s.io/component-base v0.37.0 // indirect + k8s.io/apiextensions-apiserver v0.37.2 // indirect + k8s.io/apiserver v0.37.2 // indirect + k8s.io/code-generator v0.37.2 // indirect + k8s.io/component-base v0.37.2 // indirect k8s.io/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3 // indirect k8s.io/klog/v2 v2.140.0 // indirect k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad // indirect k8s.io/streaming v0.37.2 // indirect - sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.36.0 // indirect - sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.37.0 // indirect + sigs.k8s.io/json v0.0.0-20260909141634-11ed52e25bc5 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v6 v6.4.2 // indirect - software.sslmate.com/src/go-pkcs12 v0.7.3 // indirect + software.sslmate.com/src/go-pkcs12 v0.7.4 // indirect ) diff --git a/go.sum b/go.sum index e6a3578..d99133a 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,15 @@ -cel.dev/expr v0.25.2 h1:K6j46C81hXtZQfuX60cVWQFBJahKSE2gfRbNuvr5bFs= -cel.dev/expr v0.25.2/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cel.dev/expr v0.26.0 h1:oLXvOF0jiYA5A/tmzU91pLEWZkKynhLJlC9Gw7PrKvs= +cel.dev/expr v0.26.0/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= -github.com/Azure/go-ansiterm v0.0.0-20261006220739-8c912ac31dd4 h1:m2xcjRABtG288vnlV3U/PKh/HnPURxZp50RKNUwBxM8= -github.com/Azure/go-ansiterm v0.0.0-20261006220739-8c912ac31dd4/go.mod h1:MTUE7ZuZO89FAtAwozGg6AWD83pcdefnEq5gF82MB8s= +github.com/Azure/go-ansiterm v0.0.0-20261013165250-51075c6ea6bc h1:58s5YzGPNAP7+e1uemaL0ax/NPSeJOHdRpRIowd+JDk= +github.com/Azure/go-ansiterm v0.0.0-20261013165250-51075c6ea6bc/go.mod h1:DMNF6Kxv+EcuUvVuNkvC3f+BjEEmc/Fn9aU+qiD8zpU= github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/Microsoft/go-winio v0.6.4 h1:kJF2pamtYCWXf0xAT8sAkwKC0pMl2HYBrRPHAqyUc+g= +github.com/Microsoft/go-winio v0.6.4/go.mod h1:1xl5JXG4ze/m74GH6Dc4Mwxfc3VL5siRVQjIAlHH07U= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -26,8 +26,8 @@ github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/containerd/log v0.2.0 h1:BewD/umNgVnoczglOpX8eRMyEy5t5iPlu5AIpnWDONc= +github.com/containerd/log v0.2.0/go.mod h1:/M7L7CXKcPTfNC74XzaK+5H5KbO5+4lJVpuVI6vRLoM= github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= @@ -45,8 +45,8 @@ github.com/docker/go-connections v0.8.2 h1:9d9DEokx5W7qlr0shkFXIxEA7+TTD+llwzcyk github.com/docker/go-connections v0.8.2/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY= -github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/ebitengine/purego v0.11.3 h1:OB+JLpdm7ioymhyA+6s5kbb/uOuYycAgL8NNTFc5MLg= +github.com/ebitengine/purego v0.11.3/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ= github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k= @@ -57,10 +57,10 @@ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w= github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE= github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= -github.com/fsnotify/fsnotify v1.10.0 h1:Xx/5Ydg9CeBDX/wi4VJqStNtohYjitZhhlHt4h3St1M= -github.com/fsnotify/fsnotify v1.10.0/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= -github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ= -github.com/fxamacker/cbor/v2 v2.9.1/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= +github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= +github.com/fxamacker/cbor/v2 v2.10.0 h1:HVF3T5vYwLqO81ebPirWEPNv2SMrUMD3HLnKgEr6uWE= +github.com/fxamacker/cbor/v2 v2.10.0/go.mod h1:uSwlToFuT9BZAKRxxVm3qQC8DR4tlWl7D6pf20iRYH4= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -71,48 +71,48 @@ github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/go-openapi/jsonpointer v1.0.0 h1:kR9tHqY0CtZaOPVFm622dPVNhrvYpwr4uCxgL3h1H8s= -github.com/go-openapi/jsonpointer v1.0.0/go.mod h1:Z3rw7dWu1p9IgitXCFamSlA5lmDiklEB6vkaxcNZW5Y= -github.com/go-openapi/jsonreference v1.0.0 h1:jlmTr6torcd1YgDQvSfNmRtKzYDO4FGBkrAdlAVWnpY= -github.com/go-openapi/jsonreference v1.0.0/go.mod h1:jtwdyGbJk0Xhe5Y+rwtglQP6Sb1WZST4rT32LWB+sv0= -github.com/go-openapi/swag v0.28.0 h1:xkgbOSKj6DZziNpyqRRAOt3GJGtgjgsd2RoyT30VWuw= -github.com/go-openapi/swag v0.28.0/go.mod h1:4qYnT3Cqr1p1VknOdPo70evN4rgQnAg6jwApHyxSGIg= -github.com/go-openapi/swag/cmdutils v0.28.0 h1:7TOeNtkYru1SG8Y34tDh9WBbLsMqGnptuxWiHREPZ4Q= -github.com/go-openapi/swag/cmdutils v0.28.0/go.mod h1:Sm1MVFMkF6guJJ+pQqHnQA3N0j9qALV3NxzDSv6bETM= -github.com/go-openapi/swag/conv v0.28.0 h1:GtqqbyFe7vR5Y7ehxG9W6/OvrSFdf1OLeTGp40TqxH8= -github.com/go-openapi/swag/conv v0.28.0/go.mod h1:mbUE+mzctnhxi864m0Q07SpN8OowD9JhxmxuYvZZD/k= -github.com/go-openapi/swag/fileutils v0.28.0 h1:Z04XWQD7R8Eq+7GnOrjovBxPPmZzsS4gt2H2GPGIViU= -github.com/go-openapi/swag/fileutils v0.28.0/go.mod h1:VvJFZLTZS0AI854gEQz5tk7dBESdLjiNUMSZ/th2ry8= -github.com/go-openapi/swag/jsonutils v0.28.0 h1:YIch6FwO7RXzeAnbO8Tu7dWBZeUEH+4nA0HXltVTnv4= -github.com/go-openapi/swag/jsonutils v0.28.0/go.mod h1:CYM3WlTUcagR2ZoHdz54di/cbBqt82tuxuXgAjxw+mg= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.28.0 h1:qV+VVUAx5Oro8WjVWpZeql7YReTKhT4smR4zhcOQZr0= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.28.0/go.mod h1:mofwUWx70wvskwESqRJ//k/9kURmCgyJl5m5Ppoh5kY= -github.com/go-openapi/swag/loading v0.28.0 h1:td8QZdZC9MIYGGSnSPKShKiK22I2tU5UQvuUhIBPRLU= -github.com/go-openapi/swag/loading v0.28.0/go.mod h1:rXB0QiQX5mMveXEA7ouM4KiiM9jVJe4K6BVbwhD1M4k= -github.com/go-openapi/swag/mangling v0.28.0 h1:pH8eyeNO9SLYsTMWJrurnNfKmDa28XrlA+HePVD53VM= -github.com/go-openapi/swag/mangling v0.28.0/go.mod h1:jtBE2+V+3pILxOR7Vgce+Cwp6A2PgZbvVqfNntbVs0w= -github.com/go-openapi/swag/netutils v0.28.0 h1:YXN6TALEi2pzts8/8GNm6T61HTAZsieukGZidap989k= -github.com/go-openapi/swag/netutils v0.28.0/go.mod h1:J+WYyFMLtvtCGqa6jLv+YNUmIKI3ZRQRrvfNDMoQoEQ= -github.com/go-openapi/swag/pools v0.28.0 h1:HPMZWSAfce3rdVTFcjFiCIBtDg9h4x2QlRrHipwhxeU= -github.com/go-openapi/swag/pools v0.28.0/go.mod h1:kVQefhSK5RWuRe7BXsL8htgBPAMpN7HDGpGEknqugeE= -github.com/go-openapi/swag/stringutils v0.28.0 h1:ixsc9iYgDPubHL/8nSkbnryEHpD2VRlBMLKpQyPXcDU= -github.com/go-openapi/swag/stringutils v0.28.0/go.mod h1:lzRN95CxXmA03XcDWHLOb6nOMcxCqR5rGY0lOgsfRoM= -github.com/go-openapi/swag/typeutils v0.28.0 h1:nRBKSBXjDgf01VDPB3fWeD9nQuhCOVeIYAkUx2tbkyY= -github.com/go-openapi/swag/typeutils v0.28.0/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ= -github.com/go-openapi/swag/yamlutils v0.28.0 h1:TV3JXH6DS46KUroDtMLAYHGkdWf5VDq3wVWFirmzROY= -github.com/go-openapi/swag/yamlutils v0.28.0/go.mod h1:x0q/yndZHEgk9Rx3DyDqzFUmHy55KTvIZldvF2dTJXs= -github.com/go-openapi/testify/enable/yaml/v2 v2.6.0 h1:gGHwAJ0R/5jU8BEGDbfRNR3hL68dAVi84WuOApp29B0= -github.com/go-openapi/testify/enable/yaml/v2 v2.6.0/go.mod h1:tY+St1SGq4NFl0QIqdTY4aEdbChAHxhyB77XQi9iJCo= -github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug= -github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-openapi/jsonpointer v1.0.2 h1:NbW7xT2b+l7x+JefiPGDsZWsrLk1ogrz4AHK1TTzMt8= +github.com/go-openapi/jsonpointer v1.0.2/go.mod h1:N0rI4MbNKD7xAFTiHtB+5Nhrg2j/wwYg7m7Fmb4/jk8= +github.com/go-openapi/jsonreference v1.0.3 h1:5rDbq+JsjCv6/nUDDJt83nLZoADI4w03uvHXer+4aYQ= +github.com/go-openapi/jsonreference v1.0.3/go.mod h1:OJSlMXHysgH272D9z2tiy2MGe5A9vQLHaCPb6KbYdE4= +github.com/go-openapi/swag v0.29.2 h1:9n8frkcsuQRA0INU31VbxNxt1zBaHxrHYGEf5BUjFi4= +github.com/go-openapi/swag v0.29.2/go.mod h1:RkCiX1gCVXWgLOavDXE3ALJrQ/VO2ziiIzOUs3z10xo= +github.com/go-openapi/swag/cmdutils v0.29.2 h1:cXEzX/nWCODon251f+1HgL75/R4XXML5IZxgLCWMoro= +github.com/go-openapi/swag/cmdutils v0.29.2/go.mod h1:XziaSVzYqkDvpWXzASfWajw2YvJrLscq610O2XiyqJw= +github.com/go-openapi/swag/conv v0.29.2 h1:8c9shoB8l0QRSR6ymq1llHdBWDqpIgJfjTGHx3Vuhm0= +github.com/go-openapi/swag/conv v0.29.2/go.mod h1:AZS0YigTNf8qNtD6WqJz/N4RUNmpr76SyjFGkq4+p6Q= +github.com/go-openapi/swag/fileutils v0.29.2 h1:mdUL+Vw5ah1fO1AvFCoHeIyv7YZsCz2MN3KNqd/lLVI= +github.com/go-openapi/swag/fileutils v0.29.2/go.mod h1:7QKmmodjAebaq61lGVJa8ldLdGeMF4DSgYv8tXOGGo0= +github.com/go-openapi/swag/jsonutils v0.29.2 h1:uZNSD2/rJDYAfvsLYkykTzXuyxM3QpDKV9jhRHrMu6k= +github.com/go-openapi/swag/jsonutils v0.29.2/go.mod h1:ONTdNvj3Y+IXRzfa17E+Rgt2ns/qiSOYjIo2K7v2yDs= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2 h1:w+Fd6EBOMGlC74GYGHqCLGyb3Bpams8TtNrgM/SG4jo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2/go.mod h1:HC2egPORFzbj/gf05Zrfgz8Mgplx3oW7hgGi7pjZVhM= +github.com/go-openapi/swag/loading v0.29.2 h1:QU1ry24e6r6Shoxe380Nx0X5iKkpRO+hJffsyJ2dVlY= +github.com/go-openapi/swag/loading v0.29.2/go.mod h1:DqilDjuiJKETecsS4TRopWG1acUDsfqN39ZmQhPu6uI= +github.com/go-openapi/swag/mangling v0.29.2 h1:ltdo3K0tTP4P6zWhVVWDU9D37/YYBuMJRdZxiS2Dtog= +github.com/go-openapi/swag/mangling v0.29.2/go.mod h1:RjDi4TnItAenS3cgCXSpIl1kKbjG7il6pnmQVl/8bp8= +github.com/go-openapi/swag/netutils v0.29.2 h1:dBli6jyUa93sDS/XYWShJzf4+nnVfFKfvY9SLUaUzB8= +github.com/go-openapi/swag/netutils v0.29.2/go.mod h1:1pM6Xg/Um8E1eps3umWl8Hme3ByWXOtHsvFC0CULHUE= +github.com/go-openapi/swag/pools v0.29.2 h1:PlGoDRF8WtSyXkedZZkpW3f9wDhFf3u8KtaBcmgmh8c= +github.com/go-openapi/swag/pools v0.29.2/go.mod h1:V3lhxVT4qDYRqc2MRSSbLsTYIYV/2HlHafhyEkmzLIc= +github.com/go-openapi/swag/stringutils v0.29.2 h1:lcnBxwAaysT3bMUVBfn9V/PkfVqkurpqufKU6rTUMGk= +github.com/go-openapi/swag/stringutils v0.29.2/go.mod h1:i9cdh7sGaa0nm3CqIvH5IM5h2QClk1wns2ktKeILvRI= +github.com/go-openapi/swag/typeutils v0.29.2 h1:O7aVvkTs3pXwikgtrPLenigEMdQFgONKRooQA9pgf2I= +github.com/go-openapi/swag/typeutils v0.29.2/go.mod h1:7+GDG+uz9Ke+eVt4rClZg7wklSDp8hT/mKNh/pC26TE= +github.com/go-openapi/swag/yamlutils v0.29.2 h1:IFKFFeDnuIwzfsuWRQU+rI8iL3g4XyAYjV/RlnlxPLM= +github.com/go-openapi/swag/yamlutils v0.29.2/go.mod h1:7MGqtcrK73sxQ4ceiyIf8qiXS/s09JLMdR5esK5euYQ= +github.com/go-openapi/testify/enable/yaml/v2 v2.7.0 h1:wPW6YRgx3+SID1yUy/Xwa17L8kFEaEKod2VRbJDZNUs= +github.com/go-openapi/testify/enable/yaml/v2 v2.7.0/go.mod h1:mI1M88etYbc3PhgHsWQK2kwvNwW5aGFqMPbmib+SGIs= +github.com/go-openapi/testify/v2 v2.8.0 h1:19QDx5b57p8KjO2E4sgs/woL4Akp+FGLRlVm2xn0Rho= +github.com/go-openapi/testify/v2 v2.8.0/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/cel-go v0.29.2 h1:ZtDxkeiMmz0mxbKDYiNkE5Lk7V5edMRcaaDf2jX002k= -github.com/google/cel-go v0.29.2/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8= +github.com/google/cel-go v0.31.0 h1:H0bhpFTqOvmHrBGrWKp7ZlhBm5Hh8PYUEXnwxT1LL7A= +github.com/google/cel-go v0.31.0/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8= github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c= github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -124,24 +124,24 @@ github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oX github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 h1:/Tnpcb2E0Pz/tN9s3bfEY2Q8ePCEX9iuS+cneUwncnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0/go.mod h1:zOBXOsUaBSjKgmH4OGzV1esUpR3oUSCPYVd2cUBjKYY= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.33.0 h1:5T5Ns3kMpWr+z3s5ZA0e7ljVyWNVNxK76sHPAxi5D1k= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.33.0/go.mod h1:oWNYw09cH8wl8fFgC5hKlBLxR4XfKy2KQpP8MJjeCcc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4= -github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= +github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI= +github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e h1:Q6MvJtQK/iRcRtzAscm/zF23XxJlbECiGPyRicsX+Ak= -github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= -github.com/magiconair/properties v1.18.12 h1:sT9zQpvTB3B4gzrX0tmZNTEaGyg8Zw55MFYRE32Mr9I= -github.com/magiconair/properties v1.18.12/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/lufia/plan9stats v0.0.0-20261101121723-be84dd9509a0 h1:bGmNmV0W+HWMJyDOXmbY2InjV33LK59X9ClO7AU/8e8= +github.com/lufia/plan9stats v0.0.0-20261101121723-be84dd9509a0/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= +github.com/magiconair/properties v1.18.13 h1:UzIwH+0nODFR48wsJaaiWP4oCE1Xvp168ovLKsdqy0c= +github.com/magiconair/properties v1.18.13/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -152,10 +152,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/go-archive v0.3.3 h1:OxxR9paxsluYi+zDUEXTTaIxtkK3viymW+Ka7vRhhME= github.com/moby/go-archive v0.3.3/go.mod h1:Npdv43fFqlhZW7Xo8fbm3ZMYFvAGNviUPqX21VERbcE= -github.com/moby/moby/api v1.56.1 h1:PpWkvVPB7Fr/No8w+TfyJ/I6rWZ2YPZhT3JorIg+06c= -github.com/moby/moby/api v1.56.1/go.mod h1:sZ+THbVWkjOmBPPfbnzdD/G1LuIexWhqlSHHPTDQ1Uk= -github.com/moby/moby/client v0.6.2 h1:ekSPlMccrZGcw6Scb8T9D39qE0mB+XupU/yS0zNw9N4= -github.com/moby/moby/client v0.6.2/go.mod h1:DGcnO7qmPJrqobx/ggQgQ/AUk+2wgVdQv7uxB0/mEsc= +github.com/moby/moby/api v1.57.0 h1:K2ykv5UZjwFCtmtL486T+SUEVrQ46w3v7isf214RCcw= +github.com/moby/moby/api v1.57.0/go.mod h1:pRZ1QRtx6AVhdckeFYo4DUX4ASNF0SCllhyY6aj2mgg= +github.com/moby/moby/client v0.6.3 h1:XJn2T8YdXBdMgQl7JrOx09NEBuzIpVXcsN2KDHufAKY= +github.com/moby/moby/client v0.6.3/go.mod h1:7CXNAnAhcwwqjwjXqLembJczRorLfM+5mu0d5363lCc= github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/sys/mount v0.3.5 h1:eS3fsZTjHaBihwjp4/+5Z3jxqLXYsbwxqpVSfFv3M00= @@ -164,10 +164,10 @@ github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9Kou github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= github.com/moby/sys/sequential v0.7.0 h1:ASQNGNROJSuOO6LL6bPHbKvuZu6NU8P4ldPWk31zj/8= github.com/moby/sys/sequential v0.7.0/go.mod h1:NfSTAp6V3fw4tmkD62PEcOKeZKquXT8VKCkf7aVR79o= -github.com/moby/sys/user v0.4.1 h1:RgjRlaDKi/Xmyrz4t8lyzXT6v2ooFeO/7xtchmhVWE0= -github.com/moby/sys/user v0.4.1/go.mod h1:E9QsW5WRe1kUAf7kW8hXKwu1uhsZEAdPLYHYSDudF4Y= -github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= -github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= +github.com/moby/sys/user v0.5.0 h1:5+S4lyoavGyX1DGs68NW8xpx48T9+a7ogSUc0KjZg8Y= +github.com/moby/sys/user v0.5.0/go.mod h1:4mQzP5aTmaLjDLp/dc870oNkik6E9vjRtWYwI05gvow= +github.com/moby/sys/userns v0.2.1 h1:4OvdM7BcPkASbuouHsbW3aeMJSFlYDldBRnXVZhaRk8= +github.com/moby/sys/userns v0.2.1/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -186,6 +186,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= +github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM= +github.com/pandatix/go-abnf v0.5.5/go.mod h1:AE0KD3/VNoCjGzc1gqetRKshbI4SYErXQ/8kPenR5mc= github.com/pierrec/lz4/v4 v4.1.33 h1:GjG1TJ1V4IzKP8L96muuuDNpTwd7D+l2ccXrjAbe014= github.com/pierrec/lz4/v4 v4.1.33/go.mod h1:7SE9MC2STkNtL4PIwGhjmyVwvILaGI9/COYQNBhKM/c= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -193,28 +195,28 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= -github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 h1:XA01Vk/wv9YikCi1V51yRzIHPMT5of9+cMpZoZvDn/M= +github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0= github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk= github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo= github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM= -github.com/prometheus/common v0.72.0 h1:tAYsE+sPJxIncDAobm4H5aQjmox9ZxEIIqPbiffa8G4= -github.com/prometheus/common v0.72.0/go.mod h1:77NWqAQ2tXT7BIK40qjJdw5Acrsrg1TlHAnsQi3i6mk= -github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics= -github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58= +github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI= +github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA= +github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4= +github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil/v4 v4.26.6 h1:Mzr/npDtQC/xpeEuQKHZt8Zo9CmPvhTj8nkR8w5TLDs= -github.com/shirou/gopsutil/v4 v4.26.6/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= -github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= -github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= +github.com/shirou/gopsutil/v4 v4.26.10 h1:MJN6euesJx53MVEjscYeyRSRcrdIcy3sz5k9nosjldg= +github.com/shirou/gopsutil/v4 v4.26.10/go.mod h1:XpkIrcUMQhwte/dGxu57KtnMMFsbKelI7PP23zweKBk= +github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo= +github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= -github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.1.0 h1:6W6MbVUrnMb8PEhjkqwsVLY7ryuzRfFHF4mQd7L94ag= +github.com/spf13/pflag v1.1.0/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -234,10 +236,10 @@ github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRU github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI= github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4= github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg= -github.com/twmb/franz-go v1.22.2 h1:EdwIHGzD/4mgCpl/sNS0C74JYn6cL/r2KYS+8UC96Ww= -github.com/twmb/franz-go v1.22.2/go.mod h1:HzZMc00pBWNfe0hNcNK4NxnsDNyKOoXnlTBkB4SUTjI= -github.com/twmb/franz-go/pkg/kadm v1.19.0 h1:5Nx/WWFkpNUi8Z55Skxvn9x5HOCjw+BUntSNB1kLglk= -github.com/twmb/franz-go/pkg/kadm v1.19.0/go.mod h1:emmsx5J7YPU9A7UHcSoz0fBMYVmCcJO2etylJeU0VHU= +github.com/twmb/franz-go v1.22.3 h1:RHe35s34pKefMLyL+ZYJ6mQVtfFZz4zHDHVkTyACur0= +github.com/twmb/franz-go v1.22.3/go.mod h1:OhbFLkvp6GLcN5daC7I4Q2z0W/rFP16HG+gTbe9CDC4= +github.com/twmb/franz-go/pkg/kadm v1.20.0 h1:Gx9q6UwA1QP0SXHutlT3iNpGC3dfm5DY5XDdUYrC9M8= +github.com/twmb/franz-go/pkg/kadm v1.20.0/go.mod h1:84WtODAAftpVi1KQIr+rrIaYMjk3TXBmZKv1w1pnD8Y= github.com/twmb/franz-go/pkg/kmsg v1.15.1 h1:3sj7ekbH33t73nsBcHS0wtp/PyMIViHLNItZrE8V9zM= github.com/twmb/franz-go/pkg/kmsg v1.15.1/go.mod h1:sGkGxKexpRLBThFHJLjjywcyfkK09qB/g+X+wFWZQ/A= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= @@ -246,75 +248,77 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 h1:LMuyCAyfalSjDyjdC65nK6N0zoTT63+E/u95X0JovZI= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0/go.mod h1:085m8qbm4hgc8rZWGDEa4vmyyo2c3nPxUslYUKUIU04= -go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc= -go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 h1:OFnwLJr+pF3iHrlGSzbxyuo6/6HyBlnlN1CWEJmBVcw= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0/go.mod h1:716wFneO0ov19A2beH5hjfh9AK5z/VWNAtDijp1Y0/g= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0 h1:w53CDeOA/Kurp7yRsegSr6pbbr759dOvJ+yNmWM6Hxs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0/go.mod h1:BOmGMCbAtvcJiSJ+hLuhgPLdDbimnraSl8irz3iY8sY= -go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8= -go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o= -go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI= -go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM= -go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE= -go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4= -go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c= -go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI= -go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk= -go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.47.0 h1:UFpxOpYPmMNUtOWhdb+nC1WELIgVf8z9higURrbzYU4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.47.0/go.mod h1:YBGjxe3lt0jtXoEXxGrGhv/jM7oUBUDVK7zhAvNyEjc= +go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= +go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= +go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= +go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= +go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I= +go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0= +go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw= +go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= +go.opentelemetry.io/proto/otlp v1.11.1 h1:SCrPqH9NE5CmBrOqpjNCiT0X5mGwMyGERXdogfR7Yjw= +go.opentelemetry.io/proto/otlp v1.11.1/go.mod h1:wq8W4aSf6bOy8RZyESOeQFr9Pu7wydWX/TY4sgvrTPg= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= -go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= +go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI= +go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= -go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= -golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54= -golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w= -golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= -golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= -golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c= -golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o= -golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU= -golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg= +go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM= +go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c= +golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U= +golang.org/x/exp v0.0.0-20261113113407-e3970619a1a4 h1:lfvjMWyv5q5oJgIhGfBDf7Szvu8POtgSpMy2XbXlEFs= +golang.org/x/exp v0.0.0-20261113113407-e3970619a1a4/go.mod h1:J3U+E8RzytcGvwz+uJuAP4zULJ2TkAQBnmPZMexpdXs= +golang.org/x/mod v0.43.0 h1:MFuq5J6s35W9D3IjkwyWc9vHh0nENOrt5K8Iof4ofmg= +golang.org/x/mod v0.43.0/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY= +golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= +golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= golang.org/x/oauth2 v0.38.0 h1:uW7XQbcu1eoiQS7uMJvLOjPMl04bTbmY1VeRPxvbspI= golang.org/x/oauth2 v0.38.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58= -golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= -golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs= +golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= -golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= -golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM= -golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY= -golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= -golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= -golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= -golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= -golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI= -golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/term v0.48.0 h1:G6UU1eiSB8nl3DzeUGt7Mg+2SctI8tPS6Z5/mBt6cOk= +golang.org/x/term v0.48.0/go.mod h1:BRDLHCZr2SUjIeBHHpRyQeC9xzSAVbzY2rvKgafnHf4= +golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= +golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= +golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE= +golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s= +golang.org/x/tools v0.52.1-0.20261106145633-d407941a339a h1:Yqozs0FNPRoPGS4hNGlrNwRENWr5H5nVG9sN/f+5640= +golang.org/x/tools v0.52.1-0.20261106145633-d407941a339a/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= -gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= -gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0= +gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI= -google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA= -google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= -google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= +google.golang.org/genproto/googleapis/api v0.0.0-20261110000943-09e21b237f2c h1:ofk4SEqvpf6M5VWh88xRp42IYgdVOh7gffebnDj3OqU= +google.golang.org/genproto/googleapis/api v0.0.0-20261110000943-09e21b237f2c/go.mod h1:OzYcNQzaMRKcOFRMtyLzG/cfW1SmS2eh+7UmOLLFblk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c h1:XXChExL+Tm7Ubp0x0VXUEncPLHrkXIgoVWqnxmKNbAA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= +google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -331,18 +335,18 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= k8s.io/api v0.37.2 h1:PnxqnUFy93jr2GcpWDkKOm8wfy25kT9wa572MuQS8oc= k8s.io/api v0.37.2/go.mod h1:+NVRLft99kx+Jg9v34GmHw867Dapim89TSyCsn2hK+M= -k8s.io/apiextensions-apiserver v0.37.0 h1:zRMQ3+/LIE5oZ0tVvXwYHC+dIkSP5cjNWju7AZU1LOI= -k8s.io/apiextensions-apiserver v0.37.0/go.mod h1:HU0PfSBwchHL5iDau6jjt9zU6ryWkDDlaVUiq91NK80= +k8s.io/apiextensions-apiserver v0.37.2 h1:myaUiAlm1NRLYdpAvWYTqdgeiCepFupJiRFVVueMUYw= +k8s.io/apiextensions-apiserver v0.37.2/go.mod h1:BFl1aPC89HsgFgYI+3xpFtckvkAeenDTZP84njA9yw4= k8s.io/apimachinery v0.37.2 h1:G4t9RGoPDbQML38hz/kQQiltttgd3egg2ODCR8aIc2o= k8s.io/apimachinery v0.37.2/go.mod h1:qaAvSNvgU2x07wRM95MSHSJTPQ/ob/LeNAGbeDgqQJg= -k8s.io/apiserver v0.37.0 h1:TXg7OxsOWrAH8J4Zi/gBAZuMw1Dfdd+6cca2h4qjRqo= -k8s.io/apiserver v0.37.0/go.mod h1:OddHDF4gy9qyIb8o/3+qaeP6S0vEObWLgOygVqXksv0= +k8s.io/apiserver v0.37.2 h1:9Jq73PeHAA0RThpW7ou6lBcO2+SxLcPrAgleONSMUNQ= +k8s.io/apiserver v0.37.2/go.mod h1:d0P4WZtt6XMYAo6VN8dDPRnvY3O34quI3pOuxtfgAgM= k8s.io/client-go v0.37.2 h1:sgFtyRZukGkOrsu+QgS7LYnbFFJ5ut3MchdBNduD//E= k8s.io/client-go v0.37.2/go.mod h1:bo3LFC8YbCtKFPX21Yj8puMsoJLAv/+SvuOODma0s54= -k8s.io/code-generator v0.37.0 h1:AC915wukzlVHHODAQYxvQ25WKibPh95faJ2kxf8dzuo= -k8s.io/code-generator v0.37.0/go.mod h1:qg7E/uDlyvevVRL1V8+h2z9UWmi/8gxaRka/lVXUBdk= -k8s.io/component-base v0.37.0 h1:3SdSa4+itMdFTDFTeR8CxKGmSTSMXFlKL4ky8OqjguM= -k8s.io/component-base v0.37.0/go.mod h1:LjOebp4R9y6LODWZQv102ZQxGheLcDO2ZJLAw6bbh4I= +k8s.io/code-generator v0.37.2 h1:wfx7G5OkCTJktFu7HkEDTEa6iBYr3RMi2TTC3LBLfOE= +k8s.io/code-generator v0.37.2/go.mod h1:k24CS91bM7Kk5b776drjJYvvfLT5vceiLeOzTxNsEUc= +k8s.io/component-base v0.37.2 h1:Ia9IKTg1yWrUntJU5lVetapkC9pXlLg9L6P3R1IkbcY= +k8s.io/component-base v0.37.2/go.mod h1:qq+ueHZyLfzRJzxyDoyxHWNhF1JPv4zm3hcaddXWDvY= k8s.io/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3 h1:3L6PNkMLXkU/pz3jWzaaIUz0Rs2V9h+5O51AeRC7poc= k8s.io/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3/go.mod h1:yvyl3l9E+UxlqOMUULdKTAYB0rEhsmjr7+2Vb/1pCSo= k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= @@ -351,23 +355,21 @@ k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad h1:oXImqH8mQNk7PmvzKhmN3d k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad/go.mod h1:0/mqHCVhlumdJ3BhCfnjSZQE037nAhNodh1/hK0T8/I= k8s.io/streaming v0.37.2 h1:xmzp9nbqIbjvsRcqrBYa+K5XPQ6Jy/Dm3zZ8mN916AI= k8s.io/streaming v0.37.2/go.mod h1:APlJR26ZWRcVy5bIEj0QRrKUXROtBHPcxl2NT7EAzPU= -k8s.io/utils v0.0.0-20260626114624-be93311217bd h1:Ea7fgQ5we8Y9T0OX5o0dAHzQOBRI07D/dEYRaB9ZZEs= -k8s.io/utils v0.0.0-20260626114624-be93311217bd/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= -pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= -pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.36.0 h1:/YpDJ4vReG7ZmzSpBGxduXgywWkJU9zHubgJG03MT+Y= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.36.0/go.mod h1:tJo1aepTXyR+8Xs3sUsGBDk4Ub2AM5dPAPKJx0mpm5c= +k8s.io/utils v0.0.0-20261023123148-ca04ba58ecab h1:pjQrNLaF//ytZtWwCAHtW+pqwSKjtWDqzA8+TCX37RI= +k8s.io/utils v0.0.0-20261023123148-ca04ba58ecab/go.mod h1:DdQ0BJxlQtuMlKDqdg7X5IMMQCXIk2b3d1/4M9OhUYo= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.37.0 h1:NWrO5vJ1Dw7gy2JS/iY98JEEvtmQ3lXqNwwCzzOC1gk= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.37.0/go.mod h1:x/fWe7nc0XDKUqK5XZ5nqmWKdQxvouWB7OmEAsxltiI= sigs.k8s.io/controller-runtime v0.25.2 h1:bEkK3PVOIVK9X8QWLGVhJgmFc++47vfT6wakSzAOLsQ= sigs.k8s.io/controller-runtime v0.25.2/go.mod h1:4QqLdT6z/L6Olj8JJCtvztid4/fnIiYsfaTFScegctc= sigs.k8s.io/controller-tools v0.23.0 h1:GFmPTaHSyje/kZv/4XOdR1v3rWz0/OJixwpPnGyV4Sw= sigs.k8s.io/controller-tools v0.23.0/go.mod h1:JJRl1h3BoHJWtCVgwGsITk+dusn8LatINcIBhO8aP9A= -sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= -sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/json v0.0.0-20260909141634-11ed52e25bc5 h1:k9jo7ED/fsfOcz3L1P20P5tjTNtsdQNwMOG2aKzHrl8= +sigs.k8s.io/json v0.0.0-20260909141634-11ed52e25bc5/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= sigs.k8s.io/structured-merge-diff/v6 v6.4.2 h1:qdOxHwrl2Kaag1aQEarlYcOA9vSyGCp3CIki3aW8c4Q= sigs.k8s.io/structured-merge-diff/v6 v6.4.2/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= -software.sslmate.com/src/go-pkcs12 v0.7.3 h1:JBQD3FDqYjTeyDAeZQklj2ar88ykBLtALloPJHyAauU= -software.sslmate.com/src/go-pkcs12 v0.7.3/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI= +software.sslmate.com/src/go-pkcs12 v0.7.4 h1:OvJ7g/OB9RuVAOzahlFLns6HeIcP+SJotsDqmLfhd8w= +software.sslmate.com/src/go-pkcs12 v0.7.4/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI= diff --git a/internal/cli/operator.go b/internal/cli/operator.go index b794c8a..6ff920a 100644 --- a/internal/cli/operator.go +++ b/internal/cli/operator.go @@ -73,6 +73,13 @@ func newOperatorCmd() *cobra.Command { cmd.Flags().BoolVar(&opts.EnableWebhooks, "enable-webhooks", false, "enable the validating admission webhooks for KafkaTopic, KafkaQuota, KafkaAccessPolicy, "+ "KafkaRoleBinding, KafkaUser, and KafkaMirrorTopic (requires serving certs; spec §20.3)") + cmd.Flags().BoolVar(&opts.RequireSecretLabel, "require-secret-label", true, + "only use referenced Secrets labelled gitops.monedula.dev/credential-source=true (KafkaCluster credentials "+ + "and TLS, KafkaTopic schema bodies, KafkaUser passwords); false restores the previous behaviour of reading any "+ + "Secret a resource names") + cmd.Flags().StringSliceVar(&opts.SecretNamespaces, "secret-namespaces", nil, + "comma-separated namespaces the operator may read, write and watch Secrets in (empty: all namespaces); "+ + "set it to run with namespaced Secret RBAC instead of a cluster-wide grant") cmd.Flags().StringVar(&opts.WebhookCertDir, "webhook-cert-dir", "", "directory holding the webhook server's serving cert/key (empty: controller-runtime default; only used with --enable-webhooks)") cmd.Flags().DurationVar(&opts.ResyncInterval, "resync-interval", controller.DefaultResyncInterval, diff --git a/internal/matrix/versions.yaml b/internal/matrix/versions.yaml index 344e32f..4bec4db 100644 --- a/internal/matrix/versions.yaml +++ b/internal/matrix/versions.yaml @@ -29,11 +29,17 @@ cells: tiers: [integration] capabilities: [topics, acls, quotas, scram] - # Deliberately pairs an Apache broker with a Confluent Schema Registry: a - # common real-world combination that nothing else in the suite covers. - id: ak-4.3 family: apache image: apache/kafka:4.3.1 + tiers: [integration] + capabilities: [topics, acls, quotas, scram] + + # Deliberately pairs an Apache broker with a Confluent Schema Registry: a + # common real-world combination that nothing else in the suite covers. + - id: ak-4.4 + family: apache + image: apache/kafka:4.4.0 schemaRegistryImage: confluentinc/cp-schema-registry:8.3.1 tiers: [integration, e2e] capabilities: [topics, acls, quotas, scram, schemaregistry] diff --git a/internal/operator/controller/deletion_coownership_test.go b/internal/operator/controller/deletion_coownership_test.go index f06afc9..4a19827 100644 --- a/internal/operator/controller/deletion_coownership_test.go +++ b/internal/operator/controller/deletion_coownership_test.go @@ -131,6 +131,7 @@ func TestTopicDelete_SharedACLProtectedByLivePolicy(t *testing.T) { tp := coOwnedTopic() tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} pol := policyObj("Enforce") // live co-owner c := topicCluster() @@ -184,6 +185,7 @@ func TestTopicDelete_OtherDeletingPolicyDoesNotProtect(t *testing.T) { tp := coOwnedTopic() tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} pol := policyObj("Enforce") pol.Finalizers = []string{FinalizerName} // keep it alive through Delete @@ -216,6 +218,7 @@ func TestPolicyDelete_SharedACLProtectedByLiveTopic(t *testing.T) { pol := policyObj("Enforce") pol.Spec.DeletionPolicy = "Delete" pol.Finalizers = []string{FinalizerName} + pol.Status = &v1alpha1.KafkaAccessPolicyStatus{ObservedGeneration: pol.Generation} pol.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} tp := coOwnedTopic() // live co-owner c := topicCluster() @@ -265,6 +268,7 @@ func TestTopicDelete_CoClaimantFullOrphanSkipsShield(t *testing.T) { tp := coOwnedTopic() tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} pol := policyObj("Enforce") cl := newViewFakeClient(t, s, tp, pol, topicCluster(), finalizerMirrorClaimant()) @@ -313,6 +317,7 @@ func TestTopicDelete_ViewBuildFailureBlocksDeletion(t *testing.T) { tp := coOwnedTopic() tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := topicCluster() cl := newViewFakeClient(t, s, tp, c) diff --git a/internal/operator/controller/duplicate_envtest_test.go b/internal/operator/controller/duplicate_envtest_test.go index 6af7712..1f792a6 100644 --- a/internal/operator/controller/duplicate_envtest_test.go +++ b/internal/operator/controller/duplicate_envtest_test.go @@ -276,7 +276,7 @@ func TestEnvtestUserDuplicateLoserDeletionOrphansCredential(t *testing.T) { t.Fatalf("create cluster: %v", err) } pw := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "dup-user-pw", Namespace: testNamespace}, + ObjectMeta: metav1.ObjectMeta{Name: "dup-user-pw", Namespace: testNamespace, Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{"password": []byte("pw")}, } if err := env.cl.Create(ctx, pw); err != nil { diff --git a/internal/operator/controller/duplicate_recheck_test.go b/internal/operator/controller/duplicate_recheck_test.go index 0fde825..42a0b28 100644 --- a/internal/operator/controller/duplicate_recheck_test.go +++ b/internal/operator/controller/duplicate_recheck_test.go @@ -176,6 +176,7 @@ func TestQuorumRecheck_DeletionRevealsCoClaimant(t *testing.T) { doomed := stampedUser("ns1", "svc-del", "prod", "svc-shared", dupT0) doomed.Spec.DeletionPolicy = "Delete" doomed.Finalizers = []string{FinalizerName} + doomed.Status = &v1alpha1.KafkaUserStatus{ObservedGeneration: doomed.Generation} // last reconcile applied it survivor := stampedUser("ns1", "svc-live", "prod", "svc-shared", dupLater()) cache := dupFakeClient(t, s, doomed, topicCluster()) // lagging: survivor not yet visible quorum := &countingReader{reader: dupFakeClient(t, s, survivor, topicCluster())} diff --git a/internal/operator/controller/duplicate_test.go b/internal/operator/controller/duplicate_test.go index f37feb4..f720f3b 100644 --- a/internal/operator/controller/duplicate_test.go +++ b/internal/operator/controller/duplicate_test.go @@ -586,6 +586,7 @@ func TestUserCoClaimantShield_DifferentMechanismDoesNotSkipCleanup(t *testing.T) s := topicScheme(t) doomed := stampedUser("ns1", "svc-a", "prod", "svc-shared", dupT0) doomed.Finalizers = []string{FinalizerName} // defaulted mechanism: SCRAM-SHA-512 + doomed.Status = &v1alpha1.KafkaUserStatus{ObservedGeneration: doomed.Generation} // last reconcile applied it other := stampedUser("ns1", "svc-b", "prod", "svc-shared", dupLater()) other.Spec.Mechanism = "SCRAM-SHA-256" cl := dupFakeClient(t, s, doomed, other, topicCluster()) diff --git a/internal/operator/controller/finalizer_authz_test.go b/internal/operator/controller/finalizer_authz_test.go new file mode 100644 index 0000000..0fd3d2c --- /dev/null +++ b/internal/operator/controller/finalizer_authz_test.go @@ -0,0 +1,159 @@ +package controller + +import ( + "context" + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/events" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/monedula-dev/monedula-gitops/internal/api/v1alpha1" + kafkamock "github.com/monedula-dev/monedula-gitops/internal/kafka/mock" +) + +// Finalizer cleanup-authorization gate (cleanupNotApplied + tenancy) for the +// KafkaUser, KafkaQuota and KafkaAccessPolicy finalizers: deleting a CR the +// operator refused, or whose spec changed after its last reconcile, must not +// destroy broker state that CR never managed. + +func deniedNamespaceCluster() *v1alpha1.KafkaCluster { + c := topicCluster() + c.Spec.Tenancy = &v1alpha1.TenancyConfig{AllowedNamespaces: []string{"team-*"}} + return c +} + +func validationFailed(reason string) []metav1.Condition { + return []metav1.Condition{{Type: v1alpha1.CondValidationFailed, Status: metav1.ConditionTrue, Reason: reason, Message: "denied"}} +} + +func deleteAndReconcile(t *testing.T, obj client.Object, c *v1alpha1.KafkaCluster, run func(client.Client, *events.FakeRecorder)) []string { + t.Helper() + cl := dupFakeClient(t, topicScheme(t), obj, c) + if err := cl.Delete(context.Background(), obj); err != nil { + t.Fatalf("Delete: %v", err) + } + rec := events.NewFakeRecorder(16) + run(cl, rec) + var evs []string + for len(rec.Events) > 0 { + evs = append(evs, <-rec.Events) + } + return evs +} + +func TestUserDelete_TenancyDeniedKeepsCredential(t *testing.T) { + u := stampedUser("ns1", "admin-hijack", "prod", "admin", dupT0) + u.Spec.DeletionPolicy = "Delete" + u.Finalizers = []string{FinalizerName} + u.Status = &v1alpha1.KafkaUserStatus{ObservedGeneration: u.Generation, Conditions: validationFailed("TenancyDenied")} + k := kafkamock.New(nil, nil) + evs := deleteAndReconcile(t, u, deniedNamespaceCluster(), func(cl client.Client, rec *events.FakeRecorder) { + r := &KafkaUserReconciler{Client: cl, Scheme: cl.Scheme(), Recorder: rec, Clients: stubFactory{k: k}} + if _, err := r.Reconcile(context.Background(), reqFor("ns1", "admin-hijack")); err != nil { + t.Fatalf("Reconcile: %v", err) + } + }) + if callsContain(k.Calls(), "DeleteScramCredential") { + t.Fatalf("refused KafkaUser must not delete the credential; kafka calls = %v", k.Calls()) + } + if !hasEvent(evs, reasonCleanupSkipped) { + t.Fatalf("expected a %s event, got %v", reasonCleanupSkipped, evs) + } +} + +func TestUserDelete_NeverReconciledKeepsCredential(t *testing.T) { + u := stampedUser("ns1", "fresh", "prod", "admin", dupT0) + u.Spec.DeletionPolicy = "Delete" + u.Finalizers = []string{FinalizerName} // added, but no reconcile ever recorded status + k := kafkamock.New(nil, nil) + deleteAndReconcile(t, u, topicCluster(), func(cl client.Client, rec *events.FakeRecorder) { + r := &KafkaUserReconciler{Client: cl, Scheme: cl.Scheme(), Recorder: rec, Clients: stubFactory{k: k}} + if _, err := r.Reconcile(context.Background(), reqFor("ns1", "fresh")); err != nil { + t.Fatalf("Reconcile: %v", err) + } + }) + if callsContain(k.Calls(), "DeleteScramCredential") { + t.Fatalf("never-reconciled KafkaUser must not delete the credential; kafka calls = %v", k.Calls()) + } +} + +func TestQuotaDelete_TenancyDeniedKeepsQuota(t *testing.T) { + q := stampedQuota("ns1", "strip-alice", "prod", "User:alice", dupT0) + q.Finalizers = []string{FinalizerName} + q.Status = &v1alpha1.KafkaQuotaStatus{ObservedGeneration: q.Generation} + k := kafkamock.New(nil, nil) + evs := deleteAndReconcile(t, q, deniedNamespaceCluster(), func(cl client.Client, rec *events.FakeRecorder) { + r := &KafkaQuotaReconciler{Client: cl, Scheme: cl.Scheme(), Recorder: rec, Clients: stubFactory{k: k}} + if _, err := r.Reconcile(context.Background(), reqFor("ns1", "strip-alice")); err != nil { + t.Fatalf("Reconcile: %v", err) + } + }) + if callsContain(k.Calls(), "DeleteQuota") { + t.Fatalf("quota in a denied namespace must not be deleted; kafka calls = %v", k.Calls()) + } + if !hasEvent(evs, reasonCleanupSkipped) { + t.Fatalf("expected a %s event, got %v", reasonCleanupSkipped, evs) + } +} + +func TestQuotaDelete_ReconciledQuotaIsDeleted(t *testing.T) { + q := stampedQuota("ns1", "alice", "prod", "User:alice", dupT0) + q.Finalizers = []string{FinalizerName} + q.Status = &v1alpha1.KafkaQuotaStatus{ObservedGeneration: q.Generation} + k := kafkamock.New(nil, nil) + deleteAndReconcile(t, q, topicCluster(), func(cl client.Client, rec *events.FakeRecorder) { + r := &KafkaQuotaReconciler{Client: cl, Scheme: cl.Scheme(), Recorder: rec, Clients: stubFactory{k: k}} + if _, err := r.Reconcile(context.Background(), reqFor("ns1", "alice")); err != nil { + t.Fatalf("Reconcile: %v", err) + } + }) + if !callsContain(k.Calls(), "DeleteQuota") { + t.Fatalf("an applied, in-scope quota must still be deleted; kafka calls = %v", k.Calls()) + } +} + +func TestPolicyDelete_SpecChangedAfterReconcileKeepsACLs(t *testing.T) { + pol := policyObj("Enforce") + pol.Spec.DeletionPolicy = "Delete" + pol.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} + pol.Finalizers = []string{FinalizerName} + pol.Generation = 3 // reconciled at 1; +1 deletion bump, +1 spec edit + pol.Status = &v1alpha1.KafkaAccessPolicyStatus{ObservedGeneration: 1} + k := kafkamock.New(nil, nil) + evs := deleteAndReconcile(t, pol, topicCluster(), func(cl client.Client, rec *events.FakeRecorder) { + r := &KafkaAccessPolicyReconciler{Client: cl, Scheme: cl.Scheme(), Recorder: rec, Clients: stubFactory{k: k}} + if _, err := r.Reconcile(context.Background(), reqFor(pol.Namespace, pol.Name)); err != nil { + t.Fatalf("Reconcile: %v", err) + } + }) + if callsContain(k.Calls(), "DeleteACLs") { + t.Fatalf("an unreconciled policy spec must not drive ACL deletion; kafka calls = %v", k.Calls()) + } + if !hasEvent(evs, reasonCleanupSkipped) { + t.Fatalf("expected a %s event, got %v", reasonCleanupSkipped, evs) + } +} + +func TestCleanupNotApplied(t *testing.T) { + cases := []struct { + name string + gen, observed int64 + conds []metav1.Condition + wantAuthorized bool + }{ + {"reconciled, fake client (no deletion bump)", 1, 1, nil, true}, + {"reconciled, apiserver deletion bump", 2, 1, nil, true}, + {"spec edited after deletion", 3, 1, nil, false}, + {"never reconciled", 2, 0, nil, false}, + {"refused by tenancy", 2, 1, validationFailed("TenancyDenied"), false}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got := cleanupNotApplied(tc.gen, tc.observed, tc.conds) == "" + if got != tc.wantAuthorized { + t.Fatalf("authorized = %v, want %v", got, tc.wantAuthorized) + } + }) + } +} diff --git a/internal/operator/controller/kafkaaccesspolicy_controller.go b/internal/operator/controller/kafkaaccesspolicy_controller.go index 4d2bd5f..43fb210 100644 --- a/internal/operator/controller/kafkaaccesspolicy_controller.go +++ b/internal/operator/controller/kafkaaccesspolicy_controller.go @@ -282,6 +282,28 @@ func (r *KafkaAccessPolicyReconciler) handleDeletionWithClient(ctx context.Conte r.finalizeEvent(pol, corev1.EventTypeWarning, "DeleteNotApproved", msg) return ctrl.Result{RequeueAfter: resyncInterval(r.ResyncInterval)}, nil } + // Cleanup authorization: only delete ACLs this CR was allowed to + // manage. Spec stays mutable while the CR terminates, so a tenant + // could otherwise approve deletion and then repoint spec.rules at + // another team's resources or principals to have the operator revoke + // them; and a policy the tenancy policy denies never managed its + // ACLs. Orphan instead: no broker change, deletion never wedged. + var observed int64 + var conds []metav1.Condition + if pol.Status != nil { + observed, conds = pol.Status.ObservedGeneration, pol.Status.Conditions + } + reason := cleanupNotApplied(pol.Generation, observed, conds) + if reason == "" { + if terr := reconcile.CheckPolicyTenancy(cluster.Spec.Tenancy, pol); terr != nil { + reason = terr.Error() + } + } + if reason != "" { + r.finalizeEvent(pol, corev1.EventTypeWarning, reasonCleanupSkipped, + "managed ACLs left in place: "+reason) + return r.removeFinalizer(ctx, pol) + } if err := r.deletePolicyACLs(ctx, pol, k, cluster, clusterNS); err != nil { r.finalizeEvent(pol, corev1.EventTypeWarning, "DeleteFailed", err.Error()) return ctrl.Result{}, err // transient: requeue, finalizer retained diff --git a/internal/operator/controller/kafkaaccesspolicy_controller_test.go b/internal/operator/controller/kafkaaccesspolicy_controller_test.go index fd9e801..f4781a5 100644 --- a/internal/operator/controller/kafkaaccesspolicy_controller_test.go +++ b/internal/operator/controller/kafkaaccesspolicy_controller_test.go @@ -212,6 +212,7 @@ func policyDeleteSetup(t *testing.T, deletionPolicy string, annotations map[stri pol := policyObj("Enforce") pol.Spec.DeletionPolicy = deletionPolicy pol.Finalizers = []string{FinalizerName} + pol.Status = &v1alpha1.KafkaAccessPolicyStatus{ObservedGeneration: pol.Generation} if annotations != nil { pol.Annotations = annotations } diff --git a/internal/operator/controller/kafkacluster_controller.go b/internal/operator/controller/kafkacluster_controller.go index 983a246..7d804d6 100644 --- a/internal/operator/controller/kafkacluster_controller.go +++ b/internal/operator/controller/kafkacluster_controller.go @@ -276,6 +276,17 @@ func (r *KafkaClusterReconciler) mapSecretToClusters(ctx context.Context, obj cl return out } +// unlabelledSecretsMessage explains the consequence of referenced Secrets +// lacking the credential-source label under the current Secret access policy. +func unlabelledSecretsMessage(unlabelled []string) string { + if operator.CurrentSecretAccessPolicy().RequireLabel { + return fmt.Sprintf("credential Secret(s) %s lack the %s=%q label; the operator refuses to use them "+ + "(label them, or run with --require-secret-label=false)", strings.Join(unlabelled, ", "), CredentialSourceLabel, CredentialSourceLabelValue) + } + return fmt.Sprintf("credential Secret(s) %s lack the %s=%q label; a rotation reconciles only at the periodic resync, not promptly", + strings.Join(unlabelled, ", "), CredentialSourceLabel, CredentialSourceLabelValue) +} + // setCredentialSourceUnwatchedCondition sets CondCredentialSourceUnwatched on st: // True (reason SecretNotLabeled) when a referenced credential/TLS Secret lacks // the CredentialSourceLabel — a rotation reconciles only at the resync, not @@ -308,7 +319,7 @@ func (r *KafkaClusterReconciler) setCredentialSourceUnwatchedCondition(ctx conte Type: v1alpha1.CondCredentialSourceUnwatched, Status: metav1.ConditionTrue, Reason: "SecretNotLabeled", - Message: fmt.Sprintf("credential Secret(s) %s lack the %s=%q label; a rotation reconciles only at the periodic resync, not promptly", strings.Join(unlabelled, ", "), CredentialSourceLabel, CredentialSourceLabelValue), + Message: unlabelledSecretsMessage(unlabelled), ObservedGeneration: c.Generation, }) } diff --git a/internal/operator/controller/kafkaquota_controller.go b/internal/operator/controller/kafkaquota_controller.go index a634f1c..0a53e9e 100644 --- a/internal/operator/controller/kafkaquota_controller.go +++ b/internal/operator/controller/kafkaquota_controller.go @@ -28,6 +28,7 @@ import ( "github.com/monedula-dev/monedula-gitops/internal/operator/reconcile" operatorwebhook "github.com/monedula-dev/monedula-gitops/internal/operator/webhook" "github.com/monedula-dev/monedula-gitops/internal/quota" + "github.com/monedula-dev/monedula-gitops/internal/tenancy" ) // quotaRequeueAfter is the DEFAULT periodic resync interval, used when a @@ -272,6 +273,18 @@ func (r *KafkaQuotaReconciler) handleDeletionWithClient(ctx context.Context, q * return ctrl.Result{}, nil } + // Cleanup authorization: only remove a quota this CR was allowed to + // manage. A CR in a namespace the tenancy policy denies (or whose spec was + // repointed at another entity after the last reconcile, e.g. while it + // terminates) would otherwise let a tenant strip any entity's quota by + // creating and deleting a KafkaQuota. Orphan instead: no broker change, + // and the deletion is never wedged. + if reason := r.quotaCleanupNotAuthorized(ctx, q); reason != "" { + r.finalizeEvent(q, corev1.EventTypeWarning, reasonCleanupSkipped, + "managed quota left in place: "+reason) + return r.removeFinalizer(ctx, q) + } + co, cerr := findLiveQuotaCoClaimant(ctx, r.Client, q, r.ClusterNamespace == "") // Quorum recheck (duplicate.go): only when the cached scan found NO live // co-claimant — the branch about to DESTROY broker state — re-scan through @@ -319,6 +332,32 @@ func (r *KafkaQuotaReconciler) handleDeletionWithClient(ctx context.Context, q * return r.removeFinalizer(ctx, q) } +// quotaCleanupNotAuthorized returns a non-empty reason when the finalizer +// must not delete q's broker quota: q's current spec was never reconciled, or +// the referenced cluster's tenancy policy does not allow q's namespace. +func (r *KafkaQuotaReconciler) quotaCleanupNotAuthorized(ctx context.Context, q *v1alpha1.KafkaQuota) string { + var observed int64 + var conds []metav1.Condition + if q.Status != nil { + observed, conds = q.Status.ObservedGeneration, q.Status.Conditions + } + if reason := cleanupNotApplied(q.Generation, observed, conds); reason != "" { + return reason + } + clusterNS := r.ClusterNamespace + if clusterNS == "" { + clusterNS = q.Namespace + } + var cluster v1alpha1.KafkaCluster + if err := r.Get(ctx, types.NamespacedName{Namespace: clusterNS, Name: q.Spec.ClusterRef.Name}, &cluster); err != nil { + return "cannot read the referenced KafkaCluster to check tenancy: " + err.Error() + } + if err := tenancy.CheckNamespace(cluster.Spec.Tenancy, q.Namespace); err != nil { + return err.Error() + } + return "" +} + // removeFinalizer drops the finalizer and persists it, letting Kubernetes // garbage-collect the object. No requeue. This is the single deletion-success // exit (the cleanup path plus force-removal end here). diff --git a/internal/operator/controller/kafkatopic_cleanup_authz_test.go b/internal/operator/controller/kafkatopic_cleanup_authz_test.go new file mode 100644 index 0000000..0eb3f44 --- /dev/null +++ b/internal/operator/controller/kafkatopic_cleanup_authz_test.go @@ -0,0 +1,164 @@ +package controller + +import ( + "context" + "strings" + "testing" + + "k8s.io/client-go/tools/events" + + "github.com/monedula-dev/monedula-gitops/internal/api/v1alpha1" + kafkamock "github.com/monedula-dev/monedula-gitops/internal/kafka/mock" + srmock "github.com/monedula-dev/monedula-gitops/internal/schemaregistry/mock" +) + +// Tests for the finalizer cleanup-authorization gate (handleDeletion step 1b) +// and subject tenancy: a KafkaTopic may only make the operator touch Kafka +// topics, ACLs and Schema Registry subjects that a reconcile of its applied +// spec, under the current tenancy policy, would manage. + +const inlineAvro = `{"type":"record","name":"OrderEvent","namespace":"com.example","fields":[]}` + +// tenantCluster is a schema-registry cluster that restricts ns1 to the +// "payments." prefix. +func tenantCluster() *v1alpha1.KafkaCluster { + c := schemaCluster() + c.Spec.Tenancy = &v1alpha1.TenancyConfig{ + TopicPrefixes: []v1alpha1.TopicPrefixRule{{Namespaces: []string{"ns1"}, Prefixes: []string{"payments."}}}, + } + return c +} + +// customSubjectTopic is an approved, Delete-policy payments.orders topic whose +// Custom-strategy value subject is subject. +func customSubjectTopic(subject string) *v1alpha1.KafkaTopic { + tp := topicObj("Enforce") + tp.Spec.DeletionPolicy = "Delete" + tp.Spec.Schema = &v1alpha1.TopicSchema{ + Format: "AVRO", + SubjectStrategy: "Custom", + ValueSubject: subject, + ValueSchema: &v1alpha1.ValueFrom{ValueFrom: v1alpha1.ValueSource{Inline: inlineAvro}}, + } + tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} + return tp +} + +func runTopicDeletion(t *testing.T, tp *v1alpha1.KafkaTopic, c *v1alpha1.KafkaCluster) (*kafkamock.Client, *srmock.Client, []string) { + t.Helper() + s := topicScheme(t) + tp.Finalizers = []string{FinalizerName} + cl := newTopicFakeClient(t, s, tp, c) + if err := cl.Delete(context.Background(), tp); err != nil { + t.Fatalf("Delete: %v", err) + } + k := kafkamock.New(seededTopics("payments.orders"), nil) + sr := srmock.New() + sr.Seed("payments.orders-value", "AVRO", "", inlineAvro) + sr.Seed("billing.invoices-value", "AVRO", "", inlineAvro) + rec := events.NewFakeRecorder(16) + r := &KafkaTopicReconciler{Client: cl, Scheme: s, Recorder: rec, Clients: stubFactory{k: k, sr: sr}} + if _, err := r.Reconcile(context.Background(), topicReq()); err != nil { + t.Fatalf("Reconcile delete: %v", err) + } + var evs []string + for len(rec.Events) > 0 { + evs = append(evs, <-rec.Events) + } + return k, sr, evs +} + +func hasEvent(evs []string, substr string) bool { + for _, e := range evs { + if strings.Contains(e, substr) { + return true + } + } + return false +} + +// A spec edited after the last reconcile (e.g. while the CR terminates) must +// not drive destructive cleanup: the finalizer orphans instead. +func TestTopicDelete_UnreconciledSpecSkipsCleanup(t *testing.T) { + tp := customSubjectTopic("payments.orders-value") + tp.Generation = 3 // reconciled at 1; +1 deletion bump, +1 spec edit + tp.Status = &v1alpha1.KafkaTopicStatus{ObservedGeneration: 1} + k, sr, evs := runTopicDeletion(t, tp, tenantCluster()) + if len(k.Calls()) != 0 || callsContain(sr.Calls(), "DeleteSubject") { + t.Fatalf("no cleanup expected; kafka %v, sr %v", k.Calls(), sr.Calls()) + } + if !hasEvent(evs, reasonCleanupSkipped) { + t.Fatalf("expected a %s event, got %v", reasonCleanupSkipped, evs) + } +} + +// A topic whose name the current tenancy policy denies must not have the +// operator delete that Kafka topic on its behalf. +func TestTopicDelete_TenancyDeniedTopicSkipsCleanup(t *testing.T) { + tp := customSubjectTopic("payments.orders-value") + markReconciled(tp) + c := tenantCluster() + c.Spec.Tenancy.TopicPrefixes[0].Prefixes = []string{"billing."} + k, _, evs := runTopicDeletion(t, tp, c) + if callsContain(k.Calls(), "DeleteTopic") || callsContain(k.Calls(), "DeleteACLs") { + t.Fatalf("no Kafka cleanup expected, got %v", k.Calls()) + } + if !hasEvent(evs, reasonCleanupSkipped) { + t.Fatalf("expected a %s event, got %v", reasonCleanupSkipped, evs) + } +} + +// A Custom subject outside the namespace's prefixes is never deleted, while +// the topic itself (in scope) still is. +func TestTopicDelete_ForeignSubjectNotDeleted(t *testing.T) { + tp := customSubjectTopic("billing.invoices-value") + markReconciled(tp) + k, sr, evs := runTopicDeletion(t, tp, tenantCluster()) + if !callsContain(k.Calls(), "DeleteTopic payments.orders") { + t.Fatalf("in-scope topic should still be deleted, got %v", k.Calls()) + } + if callsContain(sr.Calls(), "DeleteSubject") { + t.Fatalf("foreign subject must not be deleted, got %v", sr.Calls()) + } + if !hasEvent(evs, "billing.invoices-value left in place") { + t.Fatalf("expected a subject-left-in-place event, got %v", evs) + } +} + +// Reconcile must refuse (TenancyDenied, no registry writes) a topic whose +// Custom subject is outside the namespace's prefixes. +func TestTopicReconcile_ForeignSubjectTenancyDenied(t *testing.T) { + s := topicScheme(t) + tp := customSubjectTopic("billing.invoices-value") + cl := newTopicFakeClient(t, s, tp, tenantCluster()) + k := kafkamock.New(nil, nil) + sr := srmock.New() + r := &KafkaTopicReconciler{Client: cl, Scheme: s, Clients: stubFactory{k: k, sr: sr}} + if _, err := r.Reconcile(context.Background(), topicReq()); err != nil { + t.Fatalf("Reconcile: %v", err) + } + for _, c := range sr.Calls() { + if strings.HasPrefix(c, "Register") || strings.HasPrefix(c, "SetCompatibility") || strings.HasPrefix(c, "DeleteSubject") { + t.Fatalf("no registry mutation expected, got %v", sr.Calls()) + } + } + if callsContain(k.Calls(), "CreateTopic") { + t.Fatalf("no Kafka mutation expected, got %v", k.Calls()) + } + var got v1alpha1.KafkaTopic + if err := cl.Get(context.Background(), topicReq().NamespacedName, &got); err != nil { + t.Fatal(err) + } + if got.Status == nil || got.Status.Phase != v1alpha1.PhaseError { + t.Fatalf("expected Phase Error, got %+v", got.Status) + } + found := false + for _, cond := range got.Status.Conditions { + if cond.Reason == "TenancyDenied" && strings.Contains(cond.Message, "billing.invoices-value") { + found = true + } + } + if !found { + t.Fatalf("expected a TenancyDenied condition naming the subject, got %+v", got.Status.Conditions) + } +} diff --git a/internal/operator/controller/kafkatopic_controller.go b/internal/operator/controller/kafkatopic_controller.go index ba23d60..e77605e 100644 --- a/internal/operator/controller/kafkatopic_controller.go +++ b/internal/operator/controller/kafkatopic_controller.go @@ -35,6 +35,7 @@ import ( operatorwebhook "github.com/monedula-dev/monedula-gitops/internal/operator/webhook" "github.com/monedula-dev/monedula-gitops/internal/schemaregistry" "github.com/monedula-dev/monedula-gitops/internal/secrets" + "github.com/monedula-dev/monedula-gitops/internal/tenancy" ) // topicRequeueAfter is the DEFAULT periodic resync interval, used when a @@ -564,6 +565,25 @@ func (r *KafkaTopicReconciler) handleDeletion(ctx context.Context, topic *v1alph return r.removeFinalizer(ctx, topic) } + // 1b. Cleanup authorization. The finalizer acts with the operator's + // privileges, so it must only destroy what a reconcile of this CR was + // allowed to manage: + // - the spec must be the one last reconciled. Kubernetes keeps spec + // mutable while an object terminates, so without this gate a tenant + // could delete its topic and then repoint spec.access / spec.schema at + // another team's groups, principals or subjects to have the finalizer + // revoke or delete them; + // - the CURRENT tenancy policy must still allow the topic name, its + // consumer groups and (below, per subject) its schema subjects. + // Either failure orphans instead of blocking: no external state is + // touched, and deletion can never be wedged by a spec edit or a tenancy + // change. + if reason := cleanupNotAuthorized(topic, cluster); reason != "" { + r.finalizeEvent(topic, corev1.EventTypeWarning, reasonCleanupSkipped, + "Kafka topic, ACLs and schema subjects left in place: "+reason) + return r.removeFinalizer(ctx, topic) + } + // 2. Co-claimant scan. co, err := r.findDeletionCoClaimant(ctx, topic) if err != nil { @@ -611,6 +631,59 @@ func (r *KafkaTopicReconciler) handleDeletion(ctx context.Context, topic *v1alph return r.handleDeletionWithClient(ctx, topic, k, sr, rest, resolver, cluster, clusterNS) } +// reasonCleanupSkipped is the event reason when the finalizer orphans a +// topic's external state because cleanup is not authorized. +const reasonCleanupSkipped = "CleanupSkipped" + +// cleanupNotApplied returns a non-empty reason when a CR's current spec is +// not one the operator applied, so its finalizer must not run destructive +// cleanup: +// - the spec changed after the last reconcile (spec stays mutable while an +// object terminates, so a tenant could otherwise repoint a terminating CR +// at another team's state), or the CR was never reconciled at all (the +// finalizer is added before the validation and tenancy gates run); +// - ValidationFailed=True: the last reconcile refused the spec (invalid, +// tenancy-denied, conflicting, foreign Secret, ...) and mutated nothing, +// so there is nothing this CR owns to clean up. +// +// Only finalizers call this, i.e. for an object with a DeletionTimestamp. The +// apiserver bumps metadata.generation by exactly one when it sets the +// DeletionTimestamp of a finalized object, so observed == generation-1 is +// still "the applied spec"; any spec edit after that bumps it further. +// observed == generation is accepted too (a status written after deletion +// began, and clients such as the fake client that do not bump). +func cleanupNotApplied(generation, observed int64, conds []metav1.Condition) string { + // observed == 0: no status was ever written (generations start at 1). + if observed == 0 || (observed != generation && observed+1 != generation) { + return fmt.Sprintf("spec generation %d was never reconciled (last reconciled generation %d); "+ + "cleanup only runs for a spec the operator has applied", generation, observed) + } + if c := meta.FindStatusCondition(conds, v1alpha1.CondValidationFailed); c != nil && c.Status == metav1.ConditionTrue { + return fmt.Sprintf("the operator never applied this spec (%s: %s)", c.Reason, c.Message) + } + return "" +} + +// cleanupNotAuthorized returns a non-empty reason when the finalizer must not +// run destructive cleanup for topic (see handleDeletion step 1b): the spec +// changed since the last reconcile (status.observedGeneration lags +// metadata.generation, e.g. an edit made after deletion was requested), or +// the cluster's tenancy policy denies the topic name or a consumer group. +func cleanupNotAuthorized(topic *v1alpha1.KafkaTopic, cluster *v1alpha1.KafkaCluster) string { + var observed int64 + var conds []metav1.Condition + if topic.Status != nil { + observed, conds = topic.Status.ObservedGeneration, topic.Status.Conditions + } + if reason := cleanupNotApplied(topic.Generation, observed, conds); reason != "" { + return reason + } + if terr := reconcile.CheckTopicTenancy(cluster.Spec.Tenancy, topic, operatorwebhook.ResolvedTopicName(topic)); terr != nil { + return terr.Error() + } + return "" +} + // findDeletionCoClaimant runs the deletion co-claimant scan for topic: the // cached scan first, then — only when it found NO live co-claimant, the branch // about to destroy external state — a recheck through the uncached APIReader @@ -889,6 +962,14 @@ func (r *KafkaTopicReconciler) deleteTopicState(ctx context.Context, topic *v1al return topicAbsent, nil // do not block finalization } for _, subj := range subjects { + // Subject names can come from spec.schema rather than the topic name + // (Custom / RecordName strategies): never delete one the namespace's + // tenancy policy does not grant it. + if terr := tenancy.CheckResource(cluster.Spec.Tenancy, topic.Namespace, "subject", subj, "literal"); terr != nil { + r.finalizeEvent(topic, corev1.EventTypeWarning, "SubjectDeletionFailed", + "schema registry subject "+subj+" left in place: "+terr.Error()) + continue + } if derr := sr.DeleteSubject(ctx, subj); derr != nil { msg := "failed to delete schema registry subject " + subj + ": " + derr.Error() logger.Error(derr, "subject deletion failed", "subject", subj, "topic", topic.Spec.TopicName) diff --git a/internal/operator/controller/kafkatopic_controller_test.go b/internal/operator/controller/kafkatopic_controller_test.go index 6e62e30..5ed593f 100644 --- a/internal/operator/controller/kafkatopic_controller_test.go +++ b/internal/operator/controller/kafkatopic_controller_test.go @@ -226,6 +226,7 @@ func deleteSetup(t *testing.T, deletionPolicy string, annotations map[string]str tp := topicObj("Enforce") tp.Spec.DeletionPolicy = deletionPolicy tp.Finalizers = []string{FinalizerName} + markReconciled(tp) if annotations != nil { tp.Annotations = annotations } @@ -269,6 +270,7 @@ func TestTopicReconcile_DeleteDefaultedTopicName(t *testing.T) { tp.Spec.TopicName = "" // rely on the metadata-name default: "orders" tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := topicCluster() cl := newTopicFakeClient(t, s, tp, c) @@ -343,6 +345,7 @@ func deleteSetupWithClusterDefaults( tp := topicObj("Enforce") tp.Spec.DeletionPolicy = topicDeletionPolicy tp.Finalizers = []string{FinalizerName} + markReconciled(tp) if annotations != nil { tp.Annotations = annotations } @@ -550,6 +553,7 @@ func TestTopicReconcile_SchemaRegistered(t *testing.T) { sec := &corev1.Secret{} sec.Name = "orders-schema" sec.Namespace = "ns1" // must match the topic's namespace (refs are namespace-local) + sec.Labels = map[string]string{CredentialSourceLabel: CredentialSourceLabelValue} sec.Data = map[string][]byte{ "value.avsc": []byte(`{"type":"record","name":"Order","fields":[]}`), } @@ -755,6 +759,7 @@ func TestTopicReconcile_SelfLockoutWarningEvent(t *testing.T) { sec := &corev1.Secret{Data: map[string][]byte{"username": []byte("admin"), "password": []byte("pw")}} sec.Name = "kafka-creds" sec.Namespace = c.Namespace + sec.Labels = map[string]string{CredentialSourceLabel: CredentialSourceLabelValue} cl := newTopicFakeClient(t, s, tp, c, sec) rec := events.NewFakeRecorder(16) r := &KafkaTopicReconciler{Client: cl, Scheme: s, Recorder: rec, Clients: stubFactory{k: kafkamock.New(nil, nil)}} @@ -792,6 +797,7 @@ func TestTopicReconcile_NoSelfLockoutEventWhenListed(t *testing.T) { sec := &corev1.Secret{Data: map[string][]byte{"username": []byte("admin"), "password": []byte("pw")}} sec.Name = "kafka-creds" sec.Namespace = c.Namespace + sec.Labels = map[string]string{CredentialSourceLabel: CredentialSourceLabelValue} cl := newTopicFakeClient(t, s, tp, c, sec) rec := events.NewFakeRecorder(16) r := &KafkaTopicReconciler{Client: cl, Scheme: s, Recorder: rec, Clients: stubFactory{k: kafkamock.New(nil, nil)}} @@ -828,6 +834,7 @@ func deleteSetupWithSchema( ValueSchema: &v1alpha1.ValueFrom{ValueFrom: v1alpha1.ValueSource{Inline: body}}, } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) if annotations != nil { tp.Annotations = annotations } @@ -898,6 +905,7 @@ func TestTopicReconcile_DeleteWithSchema_KeySubjectAlsoDeleted(t *testing.T) { KeySchema: &v1alpha1.ValueFrom{ValueFrom: v1alpha1.ValueSource{Inline: avroBody}}, } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := schemaCluster() cl := newTopicFakeClient(t, s, tp, c) @@ -939,6 +947,7 @@ func TestTopicReconcile_DeleteGovernanceMode_SubjectSurvives(t *testing.T) { Compatibility: "BACKWARD", } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := schemaCluster() cl := newTopicFakeClient(t, s, tp, c) @@ -1063,6 +1072,7 @@ func TestTopicReconcile_DeleteOrphanPolicy_NoSubjectDeletion(t *testing.T) { ValueSchema: &v1alpha1.ValueFrom{ValueFrom: v1alpha1.ValueSource{Inline: avroBody}}, } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) c := schemaCluster() cl := newTopicFakeClient(t, s, tp, c) if err := cl.Delete(context.Background(), tp); err != nil { @@ -1129,6 +1139,7 @@ func TestTopicReconcile_DeleteTopicName_SecretDeleted_BodylessPath(t *testing.T) }}, } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := schemaCluster() @@ -1195,6 +1206,7 @@ func TestTopicReconcile_DeleteRecordName_SecretDeleted_SubjectDeletionFailed(t * }}, } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := schemaCluster() @@ -1255,6 +1267,7 @@ func TestTopicRecordName_Delete_InlineBody_SubjectDeleted(t *testing.T) { }}, } tp.Finalizers = []string{FinalizerName} + markReconciled(tp) tp.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} c := schemaCluster() @@ -1360,3 +1373,10 @@ func TestTopicReconcile_PassesRESTToEngine(t *testing.T) { t.Fatalf("live mirror topic mutated: %v", calls) } } + +// markReconciled records tp's current generation as reconciled, the state of +// a topic the operator has applied. The finalizer only runs destructive +// cleanup for such a topic (cleanupNotAuthorized). +func markReconciled(tp *v1alpha1.KafkaTopic) { + tp.Status = &v1alpha1.KafkaTopicStatus{ObservedGeneration: tp.Generation} +} diff --git a/internal/operator/controller/kafkatopic_finalizer_test.go b/internal/operator/controller/kafkatopic_finalizer_test.go index 25c1584..3057303 100644 --- a/internal/operator/controller/kafkatopic_finalizer_test.go +++ b/internal/operator/controller/kafkatopic_finalizer_test.go @@ -50,6 +50,9 @@ func deletingDeleteTopic(t *testing.T, annotations map[string]string, extra ...c tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} tp.Annotations = annotations + // Last reconciled at the current generation: the finalizer only cleans up a + // spec the operator has applied (cleanupNotAuthorized). + tp.Status = &v1alpha1.KafkaTopicStatus{ObservedGeneration: tp.Generation} objs := append([]client.Object{tp, topicCluster()}, extra...) cl := newTopicFakeClient(t, s, objs...) if err := cl.Delete(context.Background(), tp); err != nil { diff --git a/internal/operator/controller/kafkatopic_finalizer_verify_test.go b/internal/operator/controller/kafkatopic_finalizer_verify_test.go index d6a2b28..d84ba7c 100644 --- a/internal/operator/controller/kafkatopic_finalizer_verify_test.go +++ b/internal/operator/controller/kafkatopic_finalizer_verify_test.go @@ -47,6 +47,9 @@ func fvDeletingTopic(t *testing.T, withSchema bool) client.Client { tp.Spec.DeletionPolicy = "Delete" tp.Finalizers = []string{FinalizerName} tp.Annotations = allowDelete() + // Last reconciled at the current generation: the finalizer only cleans up a + // spec the operator has applied (cleanupNotAuthorized). + tp.Status = &v1alpha1.KafkaTopicStatus{ObservedGeneration: tp.Generation} if withSchema { tp.Spec.Schema = &v1alpha1.TopicSchema{ Format: "AVRO", diff --git a/internal/operator/controller/kafkauser_controller.go b/internal/operator/controller/kafkauser_controller.go index 6c0a9f9..e8b277c 100644 --- a/internal/operator/controller/kafkauser_controller.go +++ b/internal/operator/controller/kafkauser_controller.go @@ -29,6 +29,7 @@ import ( "github.com/monedula-dev/monedula-gitops/internal/operator/locking" "github.com/monedula-dev/monedula-gitops/internal/operator/reconcile" operatorwebhook "github.com/monedula-dev/monedula-gitops/internal/operator/webhook" + "github.com/monedula-dev/monedula-gitops/internal/tenancy" ) // KafkaUserReconciler reconciles a KafkaUser. It is the SCRAM-credential @@ -284,6 +285,17 @@ func (r *KafkaUserReconciler) handleDeletionWithClient(ctx context.Context, u *v defaulting.User(u) if u.Spec.DeletionPolicy == deletionPolicyDelete { + // Cleanup authorization: the finalizer is added before the reconcile + // engine's validation and tenancy gates run, so a KafkaUser that was + // refused (tenancy-denied namespace, invalid spec, foreign Secret) — + // or whose spec changed after its last reconcile — still carries it. + // Deleting such a CR must not delete the SCRAM credential of the + // username it names (e.g. a cluster admin's). Orphan instead. + if reason := r.userCleanupNotAuthorized(ctx, u); reason != "" { + r.finalizeEvent(u, corev1.EventTypeWarning, reasonCleanupSkipped, + "SCRAM credential left in place: "+reason) + return r.removeFinalizer(ctx, u) + } co, cerr := findLiveUserCoClaimant(ctx, r.Client, u, r.ClusterNamespace == "") // Quorum recheck (duplicate.go): only when the cached scan found NO // live co-claimant — the branch about to DESTROY broker state — @@ -324,6 +336,33 @@ func (r *KafkaUserReconciler) handleDeletionWithClient(ctx context.Context, u *v return r.removeFinalizer(ctx, u) } +// userCleanupNotAuthorized returns a non-empty reason when the finalizer must +// not delete u's SCRAM credential: u's current spec was never applied (see +// cleanupNotApplied), or the referenced cluster's tenancy policy does not +// allow u's namespace. +func (r *KafkaUserReconciler) userCleanupNotAuthorized(ctx context.Context, u *v1alpha1.KafkaUser) string { + var observed int64 + var conds []metav1.Condition + if u.Status != nil { + observed, conds = u.Status.ObservedGeneration, u.Status.Conditions + } + if reason := cleanupNotApplied(u.Generation, observed, conds); reason != "" { + return reason + } + clusterNS := r.ClusterNamespace + if clusterNS == "" { + clusterNS = u.Namespace + } + var cluster v1alpha1.KafkaCluster + if err := r.Get(ctx, types.NamespacedName{Namespace: clusterNS, Name: u.Spec.ClusterRef.Name}, &cluster); err != nil { + return "cannot read the referenced KafkaCluster to check tenancy: " + err.Error() + } + if err := tenancy.CheckNamespace(cluster.Spec.Tenancy, u.Namespace); err != nil { + return err.Error() + } + return "" +} + // removeFinalizer drops the finalizer and persists it, letting Kubernetes // garbage-collect the object (and its owner-referenced generated Secret). No // requeue. This is the single deletion-success exit (the Delete and Orphan @@ -413,6 +452,9 @@ var _ reconcile.PasswordSecretStore = (*userSecretStore)(nil) // when absent. Owned reflects a CONTROLLER owner reference to the owning // KafkaUser (UID-matched), the generate-mode adoption guard. func (s *userSecretStore) GetSecret(ctx context.Context, name string) (*reconcile.PasswordSecret, error) { + if err := operator.CheckSecretNamespace(s.owner.Namespace); err != nil { + return nil, err + } var sec corev1.Secret err := s.client.Get(ctx, types.NamespacedName{Namespace: s.owner.Namespace, Name: name}, &sec) if apierrors.IsNotFound(err) { @@ -425,6 +467,7 @@ func (s *userSecretStore) GetSecret(ctx context.Context, name string) (*reconcil Data: sec.Data, ResourceVersion: sec.ResourceVersion, Owned: metav1.IsControlledBy(&sec, s.owner), + Labeled: operator.HasCredentialSourceLabel(&sec), }, nil } @@ -435,6 +478,9 @@ func (s *userSecretStore) GetSecret(ctx context.Context, name string) (*reconcil // Owns() watch actually see its events (a user deleting it triggers prompt // regeneration instead of waiting out the resync). func (s *userSecretStore) CreateOwnedSecret(ctx context.Context, name string, data map[string][]byte) error { + if err := operator.CheckSecretNamespace(s.owner.Namespace); err != nil { + return err + } sec := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/internal/operator/controller/kafkauser_envtest_test.go b/internal/operator/controller/kafkauser_envtest_test.go index 5f73172..7aa981c 100644 --- a/internal/operator/controller/kafkauser_envtest_test.go +++ b/internal/operator/controller/kafkauser_envtest_test.go @@ -78,7 +78,7 @@ func TestEnvtestUserReferencedPasswordLifecycle(t *testing.T) { t.Fatalf("create cluster: %v", err) } secret := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "user-ref-pw", Namespace: testNamespace}, + ObjectMeta: metav1.ObjectMeta{Name: "user-ref-pw", Namespace: testNamespace, Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{"password": []byte("initial")}, } if err := env.cl.Create(ctx, secret); err != nil { @@ -225,7 +225,7 @@ func TestEnvtestUserFinalizerDelete(t *testing.T) { t.Fatalf("create cluster: %v", err) } secret := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "user-del-pw", Namespace: testNamespace}, + ObjectMeta: metav1.ObjectMeta{Name: "user-del-pw", Namespace: testNamespace, Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{"password": []byte("pw")}, } if err := env.cl.Create(ctx, secret); err != nil { @@ -276,7 +276,7 @@ func TestEnvtestUserFinalizerOrphan(t *testing.T) { t.Fatalf("create cluster: %v", err) } secret := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "user-orphan-pw", Namespace: testNamespace}, + ObjectMeta: metav1.ObjectMeta{Name: "user-orphan-pw", Namespace: testNamespace, Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{"password": []byte("pw")}, } if err := env.cl.Create(ctx, secret); err != nil { diff --git a/internal/operator/controller/rest_factory_test.go b/internal/operator/controller/rest_factory_test.go index eeba2c0..0d3f7ed 100644 --- a/internal/operator/controller/rest_factory_test.go +++ b/internal/operator/controller/rest_factory_test.go @@ -29,7 +29,7 @@ func TestRESTForRotatesSecret(t *testing.T) { s := newScheme(t) _ = corev1.AddToScheme(s) sec := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "rest", Namespace: "ns1"}, + ObjectMeta: metav1.ObjectMeta{Name: "rest", Namespace: "ns1", Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{"password": []byte("a")}, } cl := fake.NewClientBuilder().WithScheme(s).WithObjects(sec).Build() diff --git a/internal/operator/controller/secret.go b/internal/operator/controller/secret.go index 878ed82..593c371 100644 --- a/internal/operator/controller/secret.go +++ b/internal/operator/controller/secret.go @@ -7,17 +7,18 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/monedula-dev/monedula-gitops/internal/api/v1alpha1" + "github.com/monedula-dev/monedula-gitops/internal/operator" ) -// CredentialSourceLabel marks a Secret as a watched credential/TLS source. The -// operator caches/watches only Secrets carrying this label = "true" (§11.4); a -// change to such a Secret reconciles the referencing KafkaCluster AND the -// data-plane resources on it promptly instead of at the periodic resync. -const CredentialSourceLabel = "gitops.monedula.dev/credential-source" +// CredentialSourceLabel marks a Secret as an opted-in credential source: the +// operator only reads referenced Secrets carrying it (unless started with +// --require-secret-label=false), and caches/watches only those, so a change +// reconciles the referencing KafkaCluster AND the data-plane resources on it +// promptly (§11.4). Defined in package operator (operator.CredentialSourceLabel). +const CredentialSourceLabel = operator.CredentialSourceLabel -// CredentialSourceLabelValue is the value CredentialSourceLabel must carry to -// opt a Secret into the watch. -const CredentialSourceLabelValue = "true" +// CredentialSourceLabelValue is the value CredentialSourceLabel must carry. +const CredentialSourceLabelValue = operator.CredentialSourceLabelValue // ClusterSecretNamesIndex is the KafkaCluster field index of referenced Secret // names (across every secretKeyRef-bearing spec field). It lets the watch diff --git a/internal/operator/controller/substrate_locking_test.go b/internal/operator/controller/substrate_locking_test.go index 60c6284..933ff47 100644 --- a/internal/operator/controller/substrate_locking_test.go +++ b/internal/operator/controller/substrate_locking_test.go @@ -405,6 +405,7 @@ func TestSubstrateLocking_PolicyFinalizerVsTopic(t *testing.T) { tp := lockTestTopic("ns1", "orders", "prod", "payments.orders", "User:p1") pol := lockTestPolicy("ns1", "payments-access", "prod", "payments.orders", "User:svc-payments") pol.Finalizers = []string{FinalizerName} + pol.Status = &v1alpha1.KafkaAccessPolicyStatus{ObservedGeneration: pol.Generation} pol.Annotations = map[string]string{"gitops.monedula.dev/allow-delete": "true"} cl := newLockingFakeClient(t, s, c, tp, pol) if err := cl.Delete(context.Background(), pol); err != nil { diff --git a/internal/operator/k8sresolver.go b/internal/operator/k8sresolver.go index 3424817..4eb833a 100644 --- a/internal/operator/k8sresolver.go +++ b/internal/operator/k8sresolver.go @@ -69,14 +69,24 @@ func (r *K8sResolver) Resolve(vf v1alpha1.ValueFrom) (string, error) { } // readKey fetches Secret / and returns data[ref.Key], -// erroring if the Secret or the key is absent. The returned bytes are the raw +// erroring if the Secret or the key is absent, or if the Secret access policy +// (SecretAccessPolicy) rejects it. The returned bytes are the raw // Secret value and must never be logged. func (r *K8sResolver) readKey(ref *v1alpha1.SecretKeyRef) ([]byte, error) { var sec corev1.Secret key := types.NamespacedName{Namespace: r.Namespace, Name: ref.Name} + if err := CheckSecretNamespace(r.Namespace); err != nil { + return nil, fmt.Errorf("reading secret %s: %w", key, err) + } if err := r.Client.Get(r.Ctx, key, &sec); err != nil { return nil, fmt.Errorf("reading secret %s: %w", key, err) } + // Opt-in gate: a CR author who can merely NAME a Secret must not be able + // to make the operator read it (and send it to a destination the CR + // chose). See CredentialSourceLabel. + if err := CheckReferencedSecret(&sec); err != nil { + return nil, err + } v, ok := sec.Data[ref.Key] if !ok { return nil, fmt.Errorf("secret %s has no key %q", key, ref.Key) diff --git a/internal/operator/k8sresolver_test.go b/internal/operator/k8sresolver_test.go index fe08b36..1c962ab 100644 --- a/internal/operator/k8sresolver_test.go +++ b/internal/operator/k8sresolver_test.go @@ -37,7 +37,7 @@ func newResolver(t *testing.T, objs ...interface{}) *K8sResolver { func secretObj() *corev1.Secret { return &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "creds", Namespace: "ns1"}, + ObjectMeta: metav1.ObjectMeta{Name: "creds", Namespace: "ns1", Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{ "username": []byte("alice"), "ca.crt": []byte("-----BEGIN CERTIFICATE-----\nPEM\n-----END CERTIFICATE-----"), @@ -228,7 +228,7 @@ func selfSignedCAPEMForTest(t *testing.T) []byte { // Mirrors TestK8sResolver_ResolveCACertSecretKeyRef for the SR TLS path. func TestK8sResolver_SchemaRegistryTLSCACertSecretKeyRef(t *testing.T) { caSecret := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: "sr-ca", Namespace: "ns1"}, + ObjectMeta: metav1.ObjectMeta{Name: "sr-ca", Namespace: "ns1", Labels: map[string]string{CredentialSourceLabel: CredentialSourceLabelValue}}, Data: map[string][]byte{"ca.crt": selfSignedCAPEMForTest(t)}, } r := newResolver(t, caSecret) diff --git a/internal/operator/manager/manager.go b/internal/operator/manager/manager.go index 019c2a0..a3c7d2e 100644 --- a/internal/operator/manager/manager.go +++ b/internal/operator/manager/manager.go @@ -25,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "github.com/monedula-dev/monedula-gitops/internal/api/v1alpha1" + "github.com/monedula-dev/monedula-gitops/internal/operator" "github.com/monedula-dev/monedula-gitops/internal/operator/controller" "github.com/monedula-dev/monedula-gitops/internal/operator/index" "github.com/monedula-dev/monedula-gitops/internal/operator/locking" @@ -72,6 +73,14 @@ type Options struct { // default for local development and clusters that haven't installed the // webhook config yet. EnableWebhooks bool + // RequireSecretLabel makes the operator use only referenced Secrets labelled + // gitops.monedula.dev/credential-source=true (operator.SecretAccessPolicy). + // The CLI defaults it to true. + RequireSecretLabel bool + // SecretNamespaces, when non-empty, confines every Secret read, write and + // watch to these namespaces, so the operator only needs namespaced Secret + // RBAC there instead of a cluster-wide grant. Empty: all namespaces. + SecretNamespaces []string // WebhookCertDir overrides the directory the webhook server reads its serving // key/cert from. Empty uses the controller-runtime default // (/tmp/k8s-webhook-server/serving-certs). Only consulted when EnableWebhooks. @@ -203,14 +212,29 @@ func Run(ctx context.Context, opts Options) error { // not in the informer. Without this, client.Get on an unlabelled ConfigMap or // Secret would return NotFound from the label-scoped cache and break schema // resolution / credential lookups. + // Secret access policy (opt-in label, namespace scope): installed before any + // controller starts, consulted by every Secret read/write. + operator.SetSecretAccessPolicy(operator.SecretAccessPolicy{ + RequireLabel: opts.RequireSecretLabel, + Namespaces: opts.SecretNamespaces, + }) + secretCache := cache.ByObject{ + Label: labels.SelectorFromSet(labels.Set{controller.CredentialSourceLabel: controller.CredentialSourceLabelValue}), + } + if len(opts.SecretNamespaces) > 0 { + // Namespaced Secret RBAC only: a cluster-wide list/watch would be + // forbidden, so scope the Secret informer to the allowed namespaces. + secretCache.Namespaces = map[string]cache.Config{} + for _, ns := range opts.SecretNamespaces { + secretCache.Namespaces[ns] = cache.Config{} + } + } mgrOpts.Cache = cache.Options{ ByObject: map[client.Object]cache.ByObject{ &corev1.ConfigMap{}: { Label: labels.SelectorFromSet(labels.Set{controller.SchemaSourceLabel: controller.SchemaSourceLabelValue}), }, - &corev1.Secret{}: { - Label: labels.SelectorFromSet(labels.Set{controller.CredentialSourceLabel: controller.CredentialSourceLabelValue}), - }, + &corev1.Secret{}: secretCache, }, } mgrOpts.Client = client.Options{ diff --git a/internal/operator/manager/render_test.go b/internal/operator/manager/render_test.go index d86d2e6..a710d20 100644 --- a/internal/operator/manager/render_test.go +++ b/internal/operator/manager/render_test.go @@ -1,6 +1,7 @@ package manager import ( + "fmt" "os" "os/exec" "path/filepath" @@ -381,3 +382,28 @@ func TestHelmDeploymentMirrorFlags(t *testing.T) { require.NotContains(t, defaults, "--mirror-stall-threshold") require.NotContains(t, defaults, "--finalizer-verification-timeout") } + +// TestHelmSecretNamespacesScopesSecretRBAC pins rbac.secretNamespaces: the +// ClusterRole loses its cluster-wide Secret rule, each listed namespace gets a +// Role + RoleBinding granting the same Secret verbs, and the operator is told +// the same namespaces via --secret-namespaces. The default keeps today's +// cluster-wide rule and passes no flag. +func TestHelmSecretNamespacesScopesSecretRBAC(t *testing.T) { + def := helmTemplate(t) + require.NotContains(t, def, "--secret-namespaces") + require.NotContains(t, def, "--require-secret-label") + require.Contains(t, def, "- secrets") + + // Templates may be checked out with CRLF line endings (Windows); normalise. + out := strings.ReplaceAll(helmTemplate(t, "rbac.secretNamespaces={kafka-system,team-a}"), "\r\n", "\n") + rules := normaliseRules(t, extractClusterRoleRules(t, out, "-manager-role")) + require.NotContains(t, fmt.Sprint(rules), "secrets", "ClusterRole must not grant Secrets when secretNamespaces is set") + require.Contains(t, out, "--secret-namespaces=kafka-system,team-a") + for _, ns := range []string{"kafka-system", "team-a"} { + require.Contains(t, out, "kind: Role\nmetadata:\n name: t-monedula-gitops-secrets\n namespace: "+ns) + require.Contains(t, out, "kind: RoleBinding\nmetadata:\n name: t-monedula-gitops-secrets\n namespace: "+ns) + } + + off := helmTemplate(t, "requireSecretLabel=false") + require.Contains(t, off, "--require-secret-label=false") +} diff --git a/internal/operator/reconcile/aclview_test.go b/internal/operator/reconcile/aclview_test.go index 8201718..e606569 100644 --- a/internal/operator/reconcile/aclview_test.go +++ b/internal/operator/reconcile/aclview_test.go @@ -182,3 +182,35 @@ func TestReconcileTopicNilViewMatchesPerCRBehavior(t *testing.T) { t.Fatalf("nil view must keep per-CR prune semantics: %v", k.Calls()) } } + +// TestClusterACLView_AllowDenyConflictFailsClosed is the regression test for +// the cross-resource prune-consent bypass: policy A (Allow, prune=true) and +// policy B (Deny, prune=false) declare the same tuple. The view must keep the +// DENY (fail closed) and must carry B's prune veto, so a live Deny ACL is +// never a consented prune candidate on A's behalf. +func TestClusterACLView_AllowDenyConflictFailsClosed(t *testing.T) { + allow := basePolicy("Enforce") // User:svc Read on topic payments.orders + allow.Name = "a-allow" + allow.Spec.Prune = true + deny := basePolicy("Enforce") + deny.Name = "b-deny" + deny.Spec.Rules[0].Permission = "Deny" + deny.Spec.Prune = false + + for _, order := range [][]*v1alpha1.KafkaAccessPolicy{{allow, deny}, {deny, allow}} { + view := BuildClusterACLView(nil, []*v1alpha1.KafkaAccessPolicy{order[0].DeepCopy(), order[1].DeepCopy()}, nil, nil) + if len(view.Conflicts) == 0 { + t.Fatal("expected the Allow/Deny conflict to be reported") + } + for _, a := range view.DesiredACLs { + if a.Principal == "User:svc" && a.Operation == "Read" && a.Permission != "Deny" { + t.Fatalf("conflict must resolve to Deny, union kept %+v", a) + } + } + for k, info := range view.Scope { + if k.Principal == "User:svc" && info.Prune { + t.Fatalf("the Deny owner's prune=false must veto pruning on %+v", k) + } + } + } +} diff --git a/internal/operator/reconcile/reconcile.go b/internal/operator/reconcile/reconcile.go index fde39fa..6bb5ef4 100644 --- a/internal/operator/reconcile/reconcile.go +++ b/internal/operator/reconcile/reconcile.go @@ -230,15 +230,37 @@ func BuildClusterACLView(topics []*v1alpha1.KafkaTopic, policies []*v1alpha1.Kaf // FullKey() is the canonical 7-field identity (single source of truth); // the three source-attribution fields break ties across resources that // share the same identity tuple. - sort.Slice(all, func(i, j int) bool { - ki := all[i].FullKey() + "|" + all[i].SourceKind + "|" + all[i].SourceNamespace + "|" + all[i].SourceName - kj := all[j].FullKey() + "|" + all[j].SourceKind + "|" + all[j].SourceNamespace + "|" + all[j].SourceName - return ki < kj - }) - - union, _ := access.BuildDesiredSet(all) // conflicts: first-seen wins, see doc + // + // Deny sorts BEFORE Allow for the same tuple (aclViewSortKey), so a + // cross-resource Allow/Deny conflict resolves fail-closed: the Deny is the + // first-seen survivor and the Allow is dropped. Resolving toward Allow + // would let one tenant's policy override (and, with prune, delete) a Deny + // another resource put in place. + sort.Slice(all, func(i, j int) bool { return aclViewSortKey(all[i]) < aclViewSortKey(all[j]) }) + + union, _ := access.BuildDesiredSet(all) // conflicts: first-seen (Deny) wins, see doc conflicts := access.Conflicts(all) // cross-resource Allow/Deny disagreements - return &ClusterACLView{DesiredACLs: union, Scope: access.BuildScope(union), Conflicts: conflicts} + // The scope is built from EVERY contributor, not just the deduped union: + // a conflict loser is dropped from the union, but its owner's prune + // consent must still take part in the AND-merge. Building the scope from + // the union alone let the surviving side's prune=true stand as unanimous + // consent over a tuple the losing owner never agreed to prune. + return &ClusterACLView{DesiredACLs: union, Scope: access.BuildScope(all), Conflicts: conflicts} +} + +// aclViewSortKey orders ACLs for BuildClusterACLView: by the 7-field +// identity with the permission ranked Deny-first (so an Allow/Deny conflict +// on one tuple resolves to the Deny), then by source attribution to break +// ties between resources declaring the identical tuple. +func aclViewSortKey(a access.ACL) string { + perm := "1" + a.Permission + if a.Permission == "Deny" { + perm = "0Deny" + } + // FullKey is the canonical NUL-separated identity ending in the permission; + // swap that suffix for the Deny-first rank. + id := strings.TrimSuffix(a.FullKey(), a.Permission) + perm + return id + "|" + a.SourceKind + "|" + a.SourceNamespace + "|" + a.SourceName } // ReconcileTopic builds the desired state for a KafkaTopic, observes live state, @@ -311,27 +333,12 @@ func ReconcileTopic(ctx context.Context, topic *v1alpha1.KafkaTopic, cluster *v1 if cluster != nil { clusterTenancy = cluster.Spec.Tenancy } - if err := tenancy.Check(clusterTenancy, topic.Namespace, topicName); err != nil { + if err := CheckTopicTenancy(clusterTenancy, topic, topicName); err != nil { msg := err.Error() st.Phase = v1alpha1.PhaseError setTerminalValidationFailed(kindKafkaTopic, &st.Conditions, reasonTenancyDenied, msg, topic.Generation) return st, nil // terminal: needs a tenancy config or namespace change } - // Consumer GROUP names in the access block are tenancy-checked like topics - // (groups reuse topic prefixes, spec §20.2): both the acl backend (group - // Read ACLs via access.CompileTopic) and the rbac backend (DeveloperRead on - // the group via rbac.CompileTopicAccess) derive live grants from these - // names, so an unchecked group name would let a prefix-restricted namespace - // grant access to another team's consumer group. Checking once here covers - // both backends; reconcileTopicRoleBindings does not re-check. - for _, c := range topic.Spec.Access.Consumers { - if err := tenancy.CheckResource(clusterTenancy, topic.Namespace, "group", c.Group, "literal"); err != nil { - msg := err.Error() - st.Phase = v1alpha1.PhaseError - setTerminalValidationFailed(kindKafkaTopic, &st.Conditions, reasonTenancyDenied, msg, topic.Generation) - return st, nil // terminal: needs a tenancy config or namespace change - } - } // Desired ACLs (topic-local access). A conflict is a validation failure. // ACLs are only emitted when the cluster uses the "acl" backend (spec §40). @@ -367,6 +374,18 @@ func ReconcileTopic(ctx context.Context, topic *v1alpha1.KafkaTopic, cluster *v1 if err != nil { schemaResolveErr = err.Error() } else { + // Subject tenancy: subject names come from spec.schema (Custom + // valueSubject/keySubject, or the record name under RecordName), + // not only from the already-checked topic name, so each one must + // carry one of the namespace's allowed prefixes. Checked before + // any registry read or write. + for _, d := range ds { + if terr := tenancy.CheckResource(clusterTenancy, topic.Namespace, "subject", d.Subject, "literal"); terr != nil { + st.Phase = v1alpha1.PhaseError + setTerminalValidationFailed(kindKafkaTopic, &st.Conditions, reasonTenancyDenied, terr.Error(), topic.Generation) + return st, nil // terminal: needs a spec or tenancy config change + } + } desiredSchemas = ds schemaValueSubject = vs } @@ -596,14 +615,11 @@ func ReconcilePolicy(ctx context.Context, pol *v1alpha1.KafkaAccessPolicy, clust if cluster != nil { clusterTenancy = cluster.Spec.Tenancy } - for _, rule := range pol.Spec.Rules { - if err := tenancy.CheckResource(clusterTenancy, pol.Namespace, - rule.Resource.Type, rule.Resource.Name, rule.Resource.PatternType); err != nil { - msg := err.Error() - st.Phase = v1alpha1.PhaseError - setTerminalValidationFailed(kindKafkaAccessPolicy, &st.Conditions, reasonTenancyDenied, msg, pol.Generation) - return st, nil // terminal: needs a tenancy config or namespace change - } + if err := CheckPolicyTenancy(clusterTenancy, pol); err != nil { + msg := err.Error() + st.Phase = v1alpha1.PhaseError + setTerminalValidationFailed(kindKafkaAccessPolicy, &st.Conditions, reasonTenancyDenied, msg, pol.Generation) + return st, nil // terminal: needs a tenancy config or namespace change } desiredACLs, errs := access.BuildDesiredSet(access.CompilePolicy(pol)) @@ -800,6 +816,39 @@ func buildDesiredSchemas(topic *v1alpha1.KafkaTopic, topicName string, r secrets return out, valueSubject, nil } +// CheckTopicTenancy enforces the cluster tenancy policy (spec §20.2) on the +// parts of a KafkaTopic that do not need live clients: the resolved topic +// name and every consumer GROUP in the access block (groups reuse topic +// prefixes; both the acl backend's group Read ACLs and the rbac backend's +// DeveloperRead derive live grants from these names). It is shared by the +// reconcile path and the finalizer, so the finalizer never cleans up state a +// reconcile would have refused to manage. Subject names are checked +// separately (they need the schema bodies for some strategies). +func CheckTopicTenancy(t *v1alpha1.TenancyConfig, topic *v1alpha1.KafkaTopic, topicName string) error { + if err := tenancy.Check(t, topic.Namespace, topicName); err != nil { + return err + } + for _, c := range topic.Spec.Access.Consumers { + if err := tenancy.CheckResource(t, topic.Namespace, "group", c.Group, "literal"); err != nil { + return err + } + } + return nil +} + +// CheckPolicyTenancy enforces the cluster tenancy policy on every rule of a +// KafkaAccessPolicy (first denial wins). Shared by the reconcile path and the +// finalizer so the finalizer never deletes ACLs a reconcile would refuse. +func CheckPolicyTenancy(t *v1alpha1.TenancyConfig, pol *v1alpha1.KafkaAccessPolicy) error { + for _, rule := range pol.Spec.Rules { + if err := tenancy.CheckResource(t, pol.Namespace, + rule.Resource.Type, rule.Resource.Name, rule.Resource.PatternType); err != nil { + return err + } + } + return nil +} + // ManagedSubjects computes the list of Schema Registry subjects that the topic // OWNS — subjects that monedula registered and manages content for. It is used // at finalization time (spec §12 topic-deletion-driven subject deletion) to know diff --git a/internal/operator/reconcile/user.go b/internal/operator/reconcile/user.go index a492082..ef733e7 100644 --- a/internal/operator/reconcile/user.go +++ b/internal/operator/reconcile/user.go @@ -13,6 +13,7 @@ import ( "github.com/monedula-dev/monedula-gitops/internal/diff" "github.com/monedula-dev/monedula-gitops/internal/executor" "github.com/monedula-dev/monedula-gitops/internal/kafka" + "github.com/monedula-dev/monedula-gitops/internal/operator" "github.com/monedula-dev/monedula-gitops/internal/tenancy" "github.com/monedula-dev/monedula-gitops/internal/user" "github.com/monedula-dev/monedula-gitops/internal/validation" @@ -31,6 +32,10 @@ const ( // KafkaUser. TERMINAL: the operator never adopts or overwrites a foreign // Secret — a human must delete/rename it (or rename the CR). reasonForeignSecret = "ForeignSecret" + // reasonSecretNotLabeled: a referenced password Secret lacks the + // credential-source opt-in label (operator.CredentialSourceLabel) while + // the operator requires it. TERMINAL until the Secret is labelled. + reasonSecretNotLabeled = "SecretNotLabeled" ) // generatedSecretSuffix names the operator-owned Secret in generate mode: @@ -62,6 +67,9 @@ type PasswordSecret struct { // Owned is true when the Secret has a controller owner reference to the // reconciling KafkaUser. Owned bool + // Labeled is true when the Secret carries the credential-source opt-in + // label (operator.CredentialSourceLabel). + Labeled bool } // PasswordSecretStore is ReconcileUser's seam to Kubernetes Secrets in the @@ -325,6 +333,15 @@ func sourceReferencedPassword(ctx context.Context, u *v1alpha1.KafkaUser, store if sec == nil { return passwordSource{transientErr: fmt.Errorf("password secret %q not found", ref.Name)} } + // Opt-in gate (operator.SecretAccessPolicy): naming a Secret in a + // KafkaUser must not be enough to make the operator read it. + if operator.CurrentSecretAccessPolicy().RequireLabel && !sec.Labeled { + return passwordSource{ + terminalReason: reasonSecretNotLabeled, + terminalMsg: fmt.Sprintf("password secret %q is not labelled %s=%s; the operator only uses Secrets opted in with this label", + ref.Name, operator.CredentialSourceLabel, operator.CredentialSourceLabelValue), + } + } v, ok := sec.Data[ref.Key] if !ok { return passwordSource{transientErr: fmt.Errorf("password secret %q has no key %q", ref.Name, ref.Key)} diff --git a/internal/operator/reconcile/user_test.go b/internal/operator/reconcile/user_test.go index 2f9aaad..115af37 100644 --- a/internal/operator/reconcile/user_test.go +++ b/internal/operator/reconcile/user_test.go @@ -3,6 +3,7 @@ package reconcile import ( "context" "errors" + "strings" "testing" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -97,7 +98,7 @@ func generatePasswordSpec() *v1alpha1.UserPassword { // refStore returns a store holding Secret "creds" with data[password]=pw at rv. func refStore(pw, rv string) *fakeSecretStore { return &fakeSecretStore{secrets: map[string]*PasswordSecret{ - "creds": {Data: map[string][]byte{"password": []byte(pw)}, ResourceVersion: rv}, + "creds": {Data: map[string][]byte{"password": []byte(pw)}, ResourceVersion: rv, Labeled: true}, }} } @@ -553,3 +554,29 @@ func containsCall(calls []string, want string) bool { } return false } + +// TestReconcileUserReferencedUnlabelledSecretTerminal: naming a Secret in a +// KafkaUser is not enough to make the operator use it as a password; an +// unlabelled Secret is a terminal SecretNotLabeled failure with no broker write. +func TestReconcileUserReferencedUnlabelledSecretTerminal(t *testing.T) { + k := kafkamock.New(nil, nil) + u := mkUser(secretRefPassword("creds", "password")) + store := refStore("s3cr3t", "5") + store.secrets["creds"].Labeled = false + + st, err := ReconcileUser(context.Background(), u, cluster(), k, store) + if err != nil { + t.Fatalf("terminal failure must return nil error, got %v", err) + } + if st.Phase != v1alpha1.PhaseError { + t.Fatalf("phase = %q, want Error", st.Phase) + } + if s, reason, _ := condStatus(st.Conditions, v1alpha1.CondValidationFailed); s != metav1.ConditionTrue || reason != reasonSecretNotLabeled { + t.Fatalf("ValidationFailed = %v/%q, want True/%s", s, reason, reasonSecretNotLabeled) + } + for _, c := range k.Calls() { + if strings.HasPrefix(c, "Upsert") || strings.HasPrefix(c, "AlterScram") { + t.Fatalf("no credential write expected, got %v", k.Calls()) + } + } +} diff --git a/internal/operator/secretpolicy.go b/internal/operator/secretpolicy.go new file mode 100644 index 0000000..a25cdf5 --- /dev/null +++ b/internal/operator/secretpolicy.go @@ -0,0 +1,86 @@ +package operator + +import ( + "fmt" + "slices" + "sync" + + corev1 "k8s.io/api/core/v1" +) + +// CredentialSourceLabel marks a Secret as a credential source the operator may +// use. It serves two purposes: +// +// - opt-in (security): when SecretAccessPolicy.RequireLabel is on (the +// default), the operator only reads a REFERENCED Secret — KafkaCluster +// credentials and TLS material, KafkaTopic schema bodies, KafkaUser +// passwords — if it carries this label. Only a principal allowed to write +// a Secret can label it, so being able to create a CR that references a +// Secret is no longer enough to make the operator read it and send its +// contents to an endpoint the CR author chose (a confused deputy); +// - watch (§11.4): the operator caches/watches only Secrets with this label, +// so a change reconciles the referencing resources promptly. +const CredentialSourceLabel = "gitops.monedula.dev/credential-source" + +// CredentialSourceLabelValue is the value CredentialSourceLabel must carry. +const CredentialSourceLabelValue = "true" + +// SecretAccessPolicy restricts which Secrets the operator reads on behalf of +// a custom resource. The zero value is permissive; production code installs +// the configured policy once at startup via SetSecretAccessPolicy. +type SecretAccessPolicy struct { + // RequireLabel rejects referenced Secrets without + // CredentialSourceLabel=CredentialSourceLabelValue. + RequireLabel bool + // Namespaces, when non-empty, is the only set of namespaces the operator + // may read or write Secrets in (it then has RBAC there only). + Namespaces []string +} + +var ( + secretPolicyMu sync.RWMutex + secretPolicy = SecretAccessPolicy{RequireLabel: true} +) + +// SetSecretAccessPolicy installs p as the process-wide Secret access policy. +// Called once by the operator manager before controllers start; tests may +// call it (and restore the previous value) to exercise either mode. +func SetSecretAccessPolicy(p SecretAccessPolicy) { + secretPolicyMu.Lock() + defer secretPolicyMu.Unlock() + secretPolicy = SecretAccessPolicy{RequireLabel: p.RequireLabel, Namespaces: slices.Clone(p.Namespaces)} +} + +// CurrentSecretAccessPolicy returns the installed Secret access policy. +func CurrentSecretAccessPolicy() SecretAccessPolicy { + secretPolicyMu.RLock() + defer secretPolicyMu.RUnlock() + return SecretAccessPolicy{RequireLabel: secretPolicy.RequireLabel, Namespaces: slices.Clone(secretPolicy.Namespaces)} +} + +// CheckSecretNamespace returns an error when the policy confines Secret +// access to a namespace list that does not include namespace. +func CheckSecretNamespace(namespace string) error { + p := CurrentSecretAccessPolicy() + if len(p.Namespaces) == 0 || slices.Contains(p.Namespaces, namespace) { + return nil + } + return fmt.Errorf("secrets in namespace %q are outside the operator's --secret-namespaces %v", namespace, p.Namespaces) +} + +// HasCredentialSourceLabel reports whether sec carries the opt-in label. +func HasCredentialSourceLabel(sec *corev1.Secret) bool { + return sec.Labels[CredentialSourceLabel] == CredentialSourceLabelValue +} + +// CheckReferencedSecret enforces the policy on a Secret the operator read +// because a custom resource referenced it. The error names the Secret and the +// missing label, never its contents. +func CheckReferencedSecret(sec *corev1.Secret) error { + if !CurrentSecretAccessPolicy().RequireLabel || HasCredentialSourceLabel(sec) { + return nil + } + return fmt.Errorf("secret %s/%s is not labelled %s=%s; the operator only uses Secrets opted in with this label "+ + "(add it with kubectl label secret, or start the operator with --require-secret-label=false)", + sec.Namespace, sec.Name, CredentialSourceLabel, CredentialSourceLabelValue) +} diff --git a/internal/operator/secretpolicy_test.go b/internal/operator/secretpolicy_test.go new file mode 100644 index 0000000..0750a84 --- /dev/null +++ b/internal/operator/secretpolicy_test.go @@ -0,0 +1,63 @@ +package operator + +import ( + "strings" + "testing" + + "github.com/monedula-dev/monedula-gitops/internal/api/v1alpha1" +) + +// withPolicy installs p for the duration of the test. +func withPolicy(t *testing.T, p SecretAccessPolicy) { + t.Helper() + prev := CurrentSecretAccessPolicy() + SetSecretAccessPolicy(p) + t.Cleanup(func() { SetSecretAccessPolicy(prev) }) +} + +func credsRef() v1alpha1.ValueFrom { + return v1alpha1.ValueFrom{ValueFrom: v1alpha1.ValueSource{ + SecretKeyRef: &v1alpha1.SecretKeyRef{Name: "creds", Key: "username"}, + }} +} + +// A CR that merely names a Secret must not make the operator read it unless +// the Secret was opted in with the credential-source label. +func TestSecretPolicy_UnlabelledSecretRejected(t *testing.T) { + withPolicy(t, SecretAccessPolicy{RequireLabel: true}) + sec := secretObj() + sec.Labels = nil + _, err := newResolver(t, sec).Resolve(credsRef()) + if err == nil || !strings.Contains(err.Error(), CredentialSourceLabel) { + t.Fatalf("want a not-labelled error naming %s, got %v", CredentialSourceLabel, err) + } + if strings.Contains(err.Error(), "alice") { + t.Fatalf("error must not leak the Secret value: %v", err) + } +} + +func TestSecretPolicy_LabelNotRequired(t *testing.T) { + withPolicy(t, SecretAccessPolicy{RequireLabel: false}) + sec := secretObj() + sec.Labels = nil + if got, err := newResolver(t, sec).Resolve(credsRef()); err != nil || got != "alice" { + t.Fatalf("with --require-secret-label=false an unlabelled Secret is readable; got %q, %v", got, err) + } +} + +func TestSecretPolicy_NamespaceOutOfScope(t *testing.T) { + withPolicy(t, SecretAccessPolicy{RequireLabel: true, Namespaces: []string{"kafka-system"}}) + _, err := newResolver(t, secretObj()).Resolve(credsRef()) // resolver namespace ns1 + if err == nil || !strings.Contains(err.Error(), "--secret-namespaces") { + t.Fatalf("want an out-of-scope namespace error, got %v", err) + } + if err := CheckSecretNamespace("kafka-system"); err != nil { + t.Fatalf("listed namespace must be allowed: %v", err) + } +} + +func TestSecretPolicy_DefaultRequiresLabel(t *testing.T) { + if !(SecretAccessPolicy{RequireLabel: true}).RequireLabel || !CurrentSecretAccessPolicy().RequireLabel { + t.Fatal("the process default must require the credential-source label") + } +} diff --git a/internal/tenancy/tenancy.go b/internal/tenancy/tenancy.go index 1b93395..5650fb7 100644 --- a/internal/tenancy/tenancy.go +++ b/internal/tenancy/tenancy.go @@ -96,13 +96,29 @@ func IsPrefixRestricted(t *v1alpha1.TenancyConfig, namespace string) bool { } // allowedPrefixes returns the union of Prefixes from every TopicPrefixRule -// whose Namespaces globs match namespace. A non-nil empty slice is never -// returned: nil means "no rule matches" (namespace is not prefix-restricted). +// whose Namespaces globs match namespace. nil means "no rule matches" +// (namespace is not prefix-restricted). When at least one rule matches, the +// result is NON-NIL even if it is empty, so a matched namespace stays +// restricted (fail closed) and an empty set denies every name. +// +// Empty-string prefixes are dropped: strings.HasPrefix(name, "") is true for +// every name, so honouring "" would silently lift the namespace's prefix +// restriction and let it claim other tenants' topics and groups. Validation +// rejects "" up front; dropping it here keeps enforcement safe even when a +// KafkaCluster reached the operator without passing validation. func allowedPrefixes(t *v1alpha1.TenancyConfig, namespace string) []string { var allowed []string for _, rule := range t.TopicPrefixes { - if namespaceMatchesRule(rule.Namespaces, namespace) { - allowed = append(allowed, rule.Prefixes...) + if !namespaceMatchesRule(rule.Namespaces, namespace) { + continue + } + if allowed == nil { + allowed = []string{} + } + for _, p := range rule.Prefixes { + if p != "" { + allowed = append(allowed, p) + } } } return allowed @@ -118,6 +134,8 @@ func allowedPrefixes(t *v1alpha1.TenancyConfig, namespace string) []string { // call-site symmetry with ACLResource and otherwise unused); // - resourceType "group": the name is prefix-checked against the SAME // TopicPrefixes (groups reuse topic prefixes by design); +// - resourceType "subject" (a Schema Registry subject a KafkaTopic manages): +// prefix-checked against the same TopicPrefixes; // - any other resourceType (cluster, transactionalId, delegationToken): // DENIED when the namespace is prefix-restricted — these resources cannot // be scoped by a name prefix, and allowing them would let a tenant @@ -136,6 +154,13 @@ func CheckResource(t *v1alpha1.TenancyConfig, namespace, resourceType, resourceN return checkPrefix(t, namespace, "topic", resourceName) case "group": return checkPrefix(t, namespace, "group", resourceName) + case "subject": + // Schema Registry subjects reuse the topic prefixes too: a team that + // owns "payments." owns "payments."-prefixed subjects. Without this a + // prefix-restricted KafkaTopic could name another team's subject via + // the Custom / RecordName subject strategies and overwrite its + // compatibility level, register versions, or delete it on finalize. + return checkPrefix(t, namespace, "subject", resourceName) default: // cluster, transactionalId, delegationToken (and anything future): // unscopeable by prefix — fail closed for prefix-restricted namespaces. @@ -234,8 +259,10 @@ func checkPrefix(t *v1alpha1.TenancyConfig, namespace, kind, name string) error // list once via allowedPrefixes and call this directly instead of // re-deriving it per name via checkPrefix. func checkPrefixAllowed(allowed []string, namespace, kind, name string) error { - if len(allowed) == 0 { - // No rule matched this namespace: unrestricted. + if allowed == nil { + // No rule matched this namespace: unrestricted. A non-nil empty + // slice (a matching rule with no usable prefix) falls through and + // denies every name. return nil } diff --git a/internal/tenancy/tenancy_test.go b/internal/tenancy/tenancy_test.go index cd88509..06912e8 100644 --- a/internal/tenancy/tenancy_test.go +++ b/internal/tenancy/tenancy_test.go @@ -648,3 +648,38 @@ func TestCheckRoleBinding(t *testing.T) { }) } } + +// TestEmptyPrefixFailsClosed is the regression test for the empty-prefix +// tenancy bypass: an empty-string prefix (or a matching rule whose prefixes +// are all empty) must NOT lift a namespace's prefix restriction. +func TestEmptyPrefixFailsClosed(t *testing.T) { + cases := []struct { + name string + cfg *v1alpha1.TenancyConfig + }{ + {"empty-string prefix only", makeConfig(nil, []v1alpha1.TopicPrefixRule{prefixRule([]string{"team-a"}, []string{""})})}, + {"empty prefixes list", makeConfig(nil, []v1alpha1.TopicPrefixRule{prefixRule([]string{"team-a"}, nil)})}, + {"empty-string alongside real prefix", makeConfig(nil, []v1alpha1.TopicPrefixRule{prefixRule([]string{"team-a"}, []string{"", "a."})})}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + if !IsPrefixRestricted(tc.cfg, "team-a") { + t.Fatal("namespace matched by a rule must stay prefix-restricted") + } + if err := Check(tc.cfg, "team-a", "b.payments"); err == nil { + t.Error("Check: foreign topic allowed via empty prefix") + } + if err := CheckResource(tc.cfg, "team-a", "group", "b.consumers", "literal"); err == nil { + t.Error("CheckResource: foreign group allowed via empty prefix") + } + if err := CheckRoleBinding(tc.cfg, "team-a", []v1alpha1.RoleResource{{Type: "Topic", Name: "b.payments"}}); err == nil { + t.Error("CheckRoleBinding: foreign topic allowed via empty prefix") + } + }) + } + // A real prefix next to "" still works. + cfg := makeConfig(nil, []v1alpha1.TopicPrefixRule{prefixRule([]string{"team-a"}, []string{"", "a."})}) + if err := Check(cfg, "team-a", "a.orders"); err != nil { + t.Errorf("Check: own prefix denied: %v", err) + } +} diff --git a/internal/validation/validation.go b/internal/validation/validation.go index 611ad66..b245621 100644 --- a/internal/validation/validation.go +++ b/internal/validation/validation.go @@ -991,6 +991,13 @@ func validateTenancyConfig(clusterName string, t *v1alpha1.TenancyConfig) []erro errs = append(errs, errf("KafkaCluster %s: tenancy.topicPrefixes[%d].namespaces[%d]: invalid glob pattern %q: %v", clusterName, i, j, pattern, err)) } } + // An empty prefix matches every name (strings.HasPrefix(x, "") is + // always true) and would silently lift the namespace's restriction. + for j, prefix := range rule.Prefixes { + if prefix == "" { + errs = append(errs, errf("KafkaCluster %s: tenancy.topicPrefixes[%d].prefixes[%d]: prefix must be non-empty (an empty prefix matches every name)", clusterName, i, j)) + } + } } return errs diff --git a/internal/validation/validation_test.go b/internal/validation/validation_test.go index fe897d4..c57eadd 100644 --- a/internal/validation/validation_test.go +++ b/internal/validation/validation_test.go @@ -1065,6 +1065,17 @@ func TestTenancyTopicPrefixRuleEmptyPrefixesIsError(t *testing.T) { require.Contains(t, errs[0].Error(), "prefixes must be non-empty") } +func TestTenancyTopicPrefixRuleEmptyStringPrefixIsError(t *testing.T) { + cl := tenancyCluster(&v1alpha1.TenancyConfig{ + TopicPrefixes: []v1alpha1.TopicPrefixRule{ + {Namespaces: []string{"team-*"}, Prefixes: []string{"a.", ""}}, + }, + }) + errs := Validate(Input{Clusters: map[string]*v1alpha1.KafkaCluster{"prod": cl}}) + require.NotEmpty(t, errs) + require.Contains(t, errs[0].Error(), "prefixes[1]: prefix must be non-empty") +} + func TestTenancyTopicPrefixRuleBadNamespaceGlobIsError(t *testing.T) { cl := tenancyCluster(&v1alpha1.TenancyConfig{ TopicPrefixes: []v1alpha1.TopicPrefixRule{ diff --git a/quickstart/k8s/kafka/kafka.yaml b/quickstart/k8s/kafka/kafka.yaml index 2db1cf5..6f541cf 100644 --- a/quickstart/k8s/kafka/kafka.yaml +++ b/quickstart/k8s/kafka/kafka.yaml @@ -79,9 +79,22 @@ spec: app.kubernetes.io/name: kafka app.kubernetes.io/part-of: monedula-quickstart spec: + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault containers: - name: kafka image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL ports: - name: client containerPort: 9092 @@ -199,9 +212,22 @@ spec: app.kubernetes.io/part-of: monedula-quickstart spec: restartPolicy: OnFailure + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault containers: - name: bootstrap image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL command: - bash - -c diff --git a/quickstart/k8s/kafka/schema-registry.yaml b/quickstart/k8s/kafka/schema-registry.yaml index c8e56e9..867493d 100644 --- a/quickstart/k8s/kafka/schema-registry.yaml +++ b/quickstart/k8s/kafka/schema-registry.yaml @@ -73,11 +73,24 @@ spec: app.kubernetes.io/name: schema-registry app.kubernetes.io/part-of: monedula-quickstart spec: + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault initContainers: # Wait until Kafka accepts SASL/SCRAM connections on :9092, i.e. until # the kafka-scram-bootstrap Job has created the `admin` SCRAM user. - name: wait-for-kafka-sasl image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL command: - bash - -c @@ -105,6 +118,11 @@ spec: containers: - name: schema-registry image: confluentinc/cp-schema-registry:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL ports: - name: http containerPort: 8081 diff --git a/quickstart/k8s/operator/kafka-credentials.secret.yaml b/quickstart/k8s/operator/kafka-credentials.secret.yaml index 51e4b6c..ffe04d5 100644 --- a/quickstart/k8s/operator/kafka-credentials.secret.yaml +++ b/quickstart/k8s/operator/kafka-credentials.secret.yaml @@ -19,6 +19,8 @@ metadata: namespace: monedula-demo labels: app.kubernetes.io/part-of: monedula-quickstart + # Opt-in: the operator only uses Secrets carrying this label (--require-secret-label). + gitops.monedula.dev/credential-source: "true" type: Opaque stringData: kafka-username: admin diff --git a/scenarios/clusters/auth-mtls/compose.apache.yaml b/scenarios/clusters/auth-mtls/compose.apache.yaml index 049a52b..0888575 100644 --- a/scenarios/clusters/auth-mtls/compose.apache.yaml +++ b/scenarios/clusters/auth-mtls/compose.apache.yaml @@ -18,7 +18,7 @@ # bootstrap step to translate). services: kafka: - image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.3.1} + image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.4.0} entrypoint: - bash - -c diff --git a/scenarios/clusters/auth-oauth/compose.apache.yaml b/scenarios/clusters/auth-oauth/compose.apache.yaml index b01e929..4f76432 100644 --- a/scenarios/clusters/auth-oauth/compose.apache.yaml +++ b/scenarios/clusters/auth-oauth/compose.apache.yaml @@ -16,7 +16,7 @@ # SCRAM bootstrap step. services: kafka: - image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.3.1} + image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.4.0} healthcheck: test: ["CMD", "/opt/kafka/bin/kafka-broker-api-versions.sh", "--bootstrap-server", "kafka:9094"] interval: 10s diff --git a/scenarios/clusters/auth-sasl-ssl/compose.apache.yaml b/scenarios/clusters/auth-sasl-ssl/compose.apache.yaml index 13a94cb..d85e8f2 100644 --- a/scenarios/clusters/auth-sasl-ssl/compose.apache.yaml +++ b/scenarios/clusters/auth-sasl-ssl/compose.apache.yaml @@ -14,7 +14,7 @@ # Confluent one (/etc/confluent/docker/run) it wraps in compose.yaml. services: kafka: - image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.3.1} + image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.4.0} entrypoint: - bash - -c @@ -33,7 +33,7 @@ services: start_period: 30s kafka-init: - image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.3.1} + image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.4.0} command: - | set -euo pipefail diff --git a/scenarios/clusters/auth-sasl-ssl/k8s/kafka-tls-secret.yaml b/scenarios/clusters/auth-sasl-ssl/k8s/kafka-tls-secret.yaml index c810f03..61000ef 100644 --- a/scenarios/clusters/auth-sasl-ssl/k8s/kafka-tls-secret.yaml +++ b/scenarios/clusters/auth-sasl-ssl/k8s/kafka-tls-secret.yaml @@ -38,5 +38,7 @@ metadata: labels: app.kubernetes.io/name: kafka-ca app.kubernetes.io/part-of: monedula-e2e + # Opt-in: the operator only uses Secrets carrying this label (--require-secret-label). + gitops.monedula.dev/credential-source: "true" data: ca.crt: diff --git a/scenarios/clusters/auth-sasl-ssl/k8s/kafka.yaml b/scenarios/clusters/auth-sasl-ssl/k8s/kafka.yaml index 241f1db..52395a0 100644 --- a/scenarios/clusters/auth-sasl-ssl/k8s/kafka.yaml +++ b/scenarios/clusters/auth-sasl-ssl/k8s/kafka.yaml @@ -68,11 +68,24 @@ spec: app.kubernetes.io/name: kafka app.kubernetes.io/part-of: monedula-e2e spec: + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault initContainers: # Combine server.crt + server.key into a PEM keystore file before the # broker starts. The broker reads ssl.keystore.location which points here. - name: build-pem-keystore image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL command: - bash - -c @@ -96,6 +109,11 @@ spec: containers: - name: kafka image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL ports: - name: client containerPort: 9092 @@ -217,9 +235,22 @@ spec: app.kubernetes.io/part-of: monedula-e2e spec: restartPolicy: OnFailure + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault containers: - name: bootstrap image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL command: - bash - -c diff --git a/scenarios/clusters/shared-sasl/compose.apache.yaml b/scenarios/clusters/shared-sasl/compose.apache.yaml index 04e358d..de9050f 100644 --- a/scenarios/clusters/shared-sasl/compose.apache.yaml +++ b/scenarios/clusters/shared-sasl/compose.apache.yaml @@ -11,7 +11,7 @@ # /opt/kafka/bin is NOT on PATH, and the scripts carry a .sh suffix. services: kafka: - image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.3.1} + image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.4.0} healthcheck: test: ["CMD", "/opt/kafka/bin/kafka-broker-api-versions.sh", "--bootstrap-server", "kafka:9094"] interval: 10s @@ -20,7 +20,7 @@ services: start_period: 20s kafka-init: - image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.3.1} + image: ${MONEDULA_KAFKA_IMAGE:-apache/kafka:4.4.0} command: - | set -euo pipefail diff --git a/scenarios/clusters/shared-sasl/k8s/kafka.yaml b/scenarios/clusters/shared-sasl/k8s/kafka.yaml index 98b04eb..d719e79 100644 --- a/scenarios/clusters/shared-sasl/k8s/kafka.yaml +++ b/scenarios/clusters/shared-sasl/k8s/kafka.yaml @@ -84,9 +84,22 @@ spec: # KAFKA_* env vars as broker config overrides; service-injected vars like # KAFKA_PORT and KAFKA_SERVICE_PORT corrupt the generated server.properties. enableServiceLinks: false + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault containers: - name: kafka image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL ports: - name: client containerPort: 9092 @@ -204,9 +217,22 @@ spec: app.kubernetes.io/part-of: monedula-quickstart spec: restartPolicy: OnFailure + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault containers: - name: bootstrap image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL command: - bash - -c diff --git a/scenarios/clusters/shared-sasl/k8s/schema-registry.yaml b/scenarios/clusters/shared-sasl/k8s/schema-registry.yaml index 32ebd2e..e9b996d 100644 --- a/scenarios/clusters/shared-sasl/k8s/schema-registry.yaml +++ b/scenarios/clusters/shared-sasl/k8s/schema-registry.yaml @@ -78,11 +78,24 @@ spec: # entrypoint interprets ALL SCHEMA_REGISTRY_* env vars as config overrides; # service-injected vars like SCHEMA_REGISTRY_PORT corrupt the config. enableServiceLinks: false + # Confluent images run as appuser (uid/gid 1000); never run as root. + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault initContainers: # Wait until Kafka accepts SASL/SCRAM connections on :9092, i.e. until # the kafka-scram-bootstrap Job has created the `admin` SCRAM user. - name: wait-for-kafka-sasl image: confluentinc/cp-kafka:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL command: - bash - -c @@ -110,6 +123,11 @@ spec: containers: - name: schema-registry image: confluentinc/cp-schema-registry:8.3.1 + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL ports: - name: http containerPort: 8081 diff --git a/test/e2e/k8s/lib.bash b/test/e2e/k8s/lib.bash index f45c8d9..aad06dc 100644 --- a/test/e2e/k8s/lib.bash +++ b/test/e2e/k8s/lib.bash @@ -230,12 +230,16 @@ setup_auth_profile() { --from-file=client.crt="${dir}/certs/client.crt" \ --from-file=client.key="${dir}/certs/client.key" \ --dry-run=client -o yaml | kubectl apply -f - + # Opt the Secret in: the operator only uses labelled Secrets (--require-secret-label). + kubectl -n "${E2E_NS}" label secret kafka-mtls gitops.monedula.dev/credential-source=true --overwrite ;; auth-oauth) kubectl -n "${E2E_NS}" create secret generic kafka-oauth \ --from-literal=client-id=monedula \ --from-literal=client-secret=monedula-secret \ --dry-run=client -o yaml | kubectl apply -f - + # Opt the Secret in: the operator only uses labelled Secrets (--require-secret-label). + kubectl -n "${E2E_NS}" label secret kafka-oauth gitops.monedula.dev/credential-source=true --overwrite ;; auth-mds) kubectl -n "${E2E_NS}" create secret generic kafka-mds \ @@ -244,6 +248,8 @@ setup_auth_profile() { --from-literal=mds-username=mds \ --from-literal=mds-password=mds-secret \ --dry-run=client -o yaml | kubectl apply -f - + # Opt the Secret in: the operator only uses labelled Secrets (--require-secret-label). + kubectl -n "${E2E_NS}" label secret kafka-mds gitops.monedula.dev/credential-source=true --overwrite ;; auth-sasl-ssl) kubectl -n "${E2E_NS}" create secret generic kafka-sasl-ssl \ @@ -251,6 +257,8 @@ setup_auth_profile() { --from-literal=scram-username=admin \ --from-literal=scram-password=admin-secret \ --dry-run=client -o yaml | kubectl apply -f - + # Opt the Secret in: the operator only uses labelled Secrets (--require-secret-label). + kubectl -n "${E2E_NS}" label secret kafka-sasl-ssl gitops.monedula.dev/credential-source=true --overwrite ;; *) echo "setup_auth_profile: unknown profile ${profile}" >&2; return 1 ;; diff --git a/test/e2e/k8s/setup.sh b/test/e2e/k8s/setup.sh index adb15a4..ee70dd6 100755 --- a/test/e2e/k8s/setup.sh +++ b/test/e2e/k8s/setup.sh @@ -126,6 +126,8 @@ metadata: namespace: monedula-e2e labels: app.kubernetes.io/part-of: monedula-e2e + # Opt-in: the operator only uses Secrets with this label (--require-secret-label). + gitops.monedula.dev/credential-source: "true" type: Opaque stringData: kafka-username: admin @@ -183,12 +185,16 @@ CERTS_DIR="${REPO_ROOT}/scenarios/clusters/auth-sasl-ssl/certs" kubectl -n "${E2E_NS}" create secret generic kafka-ca \ --from-file=ca.crt="${CERTS_DIR}/ca.crt" \ --dry-run=client -o yaml | kubectl apply -f - +# Opt the Secret in: the operator only uses labelled Secrets (--require-secret-label). +kubectl -n "${E2E_NS}" label secret kafka-ca gitops.monedula.dev/credential-source=true --overwrite kubectl -n "${E2E_NS}" create secret generic kafka-tls \ --from-file=ca.crt="${CERTS_DIR}/ca.crt" \ --from-file=server.crt="${CERTS_DIR}/server.crt" \ --from-file=server.key="${CERTS_DIR}/server.key" \ --dry-run=client -o yaml | kubectl apply -f - +# Opt the Secret in: the operator only uses labelled Secrets (--require-secret-label). +kubectl -n "${E2E_NS}" label secret kafka-tls gitops.monedula.dev/credential-source=true --overwrite echo " NOTE: scenario 04-sasl-ssl runs against the shared-sasl broker too." echo " The shared broker now runs on the host via docker-compose (SASL_PLAINTEXT)," From 46d4f263e454561e43d561ed40212fbb0ac2b783 Mon Sep 17 00:00:00 2001 From: Michal Matloka Date: Fri, 13 Nov 2026 22:52:53 +0100 Subject: [PATCH 2/2] style: gofmt duplicate_test.go --- internal/operator/controller/duplicate_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/operator/controller/duplicate_test.go b/internal/operator/controller/duplicate_test.go index f720f3b..8b4e4fa 100644 --- a/internal/operator/controller/duplicate_test.go +++ b/internal/operator/controller/duplicate_test.go @@ -585,7 +585,7 @@ func TestUserCoClaimantShield_DeletingWinnerOrphansToLoser(t *testing.T) { func TestUserCoClaimantShield_DifferentMechanismDoesNotSkipCleanup(t *testing.T) { s := topicScheme(t) doomed := stampedUser("ns1", "svc-a", "prod", "svc-shared", dupT0) - doomed.Finalizers = []string{FinalizerName} // defaulted mechanism: SCRAM-SHA-512 + doomed.Finalizers = []string{FinalizerName} // defaulted mechanism: SCRAM-SHA-512 doomed.Status = &v1alpha1.KafkaUserStatus{ObservedGeneration: doomed.Generation} // last reconcile applied it other := stampedUser("ns1", "svc-b", "prod", "svc-shared", dupLater()) other.Spec.Mechanism = "SCRAM-SHA-256"