Repository navigation
Tighten unused ConfigMap and Secret audit checks - #1067
Merged
Merged
Conversation
nadaverell
force-pushed
the
nadav/sky-1100-unused-config-precision
branch
4 times, most recently
from
June 30, 2026 21:44
275427e to
bf09d52
Compare
nadaverell
force-pushed
the
nadav/sky-1100-unused-config-precision
branch
from
July 4, 2026 14:01
bf09d52 to
b71e516
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
â Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0af1464. Configure here.
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
The
Unused ConfigMap or Secretaudit check can lead an operator toward deletion, so false positives are the dangerous failure mode. It previously credited direct Pod refs and a few controller refs, but missed several real consumption patterns: workload templates, ServiceAccount pull-secret defaults, supported CRD refs, platform/controller-owned artifacts, dynamic sidecar-loaded ConfigMaps, leader-election locks, managed add-on Secrets, and selected controller config objects consumed by convention.Linear: SKY-1100
What changed
imagePullSecretswhen a PodSpec relies on ServiceAccount admission defaults, including the implicitdefaultServiceAccount.nodePublishSecretRef, and legacy in-tree volume secret refs in the consumed-resource index.WatchedGVRs/ListWatchedonly and does not start new informers from the audit request path.imagePullSecretswhen they omit explicit pull secrets, and cert-manager ClusterIssuer secrets use the cached cert-manager controller's cluster-resource namespace when it can be inferred.gmp-system/webhook-tlsSecret shape.secretInConfigMapso broad keys likeauth,token,secret, andcredentialsrequire a secret-looking value. Low-information settings such asauth_mode=oidc,token_ttl=3600, credentials file paths, Secret-name references, and non-credential URLs no longer fire; credential URLs with username or password userinfo still do.Testing
go test ./internal/audit -run 'TestDynamicConfigObjectRefs|TestListDynamicConfigObjectRefsFiltersByTargetNamespace'go test ./internal/k8s -run 'TestChartGrantsEveryWatchedCRDGroup|TestCapabilitiesAlignment'cd pkg && go test ./audit -run 'TestOrphanConfigMapSecret|TestSecretInConfigMap'cd pkg && go test ./auditmake testmake buildcd pkg && go test ./audit -run 'TestOrphanConfigMapSecret'Live validation
/api/audit?raw=truereturned valid audit JSON, and the orphan check stayed nonzero rather than being blanket-suppressed.certificateRefson three GKE clusters: 7 total live Gateway Secret refs checked, 0 were incorrectly reported as orphaned.orphanConfigMapSecret12 -> 7; known platform rows checked: 0 remaining.orphanConfigMapSecret10 -> 2; known platform rows checked: 0 remaining.orphanConfigMapSecret885 -> 881; known platform rows checked: 0 remaining.orphanConfigMapSecret89 -> 22; known platform/cert-manager issuer rows checked: 0 remaining.control-plane.alpha.kubernetes.io/leader.gmp-system/webhook-tlscarries GKE managed-prometheus metadata.orphanConfigMapSecretresults.Risk / blast radius
Blast radius is limited to audit finding precision for ConfigMap/Secret cleanup and ConfigMap-secret warnings. No resources are mutated, and no topology/cache/API write behavior changes.
The main risk is over-suppression: hiding a real unused ConfigMap/Secret because it happens to match a platform, dynamic-loader, or controller-config shape. Mitigations are exact metadata keys, namespace/name gates where needed, managed-add-on evidence for the GKE Secret, controller labels for Argo Workflows/CNPG config, and negative tests for same-looking ordinary objects.
Runtime cost remains bounded. The audit scan itself stays cache-only: it checks an explicit handler table before reading cached objects, and it never calls
EnsureWatching, discovery, or live KubernetesList()from the request path. The added apiserver/watch cost is startup warmup for a small set of Radar-supported integration CRDs when those CRDs are installed.Product tradeoff:
secretInConfigMapis now more precision-biased, so very short real secrets under ambiguous keys may be missed. Terminal Jobs and completed Pods no longer suppress orphan findings; this assumes completed workload artifacts are historical rather than active consumers. Some ambiguous controller-output, non-modeled chart-internal config, and IstioDestinationRuleTLS credential namespace cases remain intentionally uncovered rather than guessed.