Skip to content

fix(aws,k8s): guard original tag auditors against nil clients; assert k8s provider interface#30

Merged
stxkxs merged 1 commit into
mainfrom
fix/k8s-interface-assertion-tags-nil-guard
Jun 7, 2026
Merged

fix(aws,k8s): guard original tag auditors against nil clients; assert k8s provider interface#30
stxkxs merged 1 commit into
mainfrom
fix/k8s-interface-assertion-tags-nil-guard

Conversation

@stxkxs

@stxkxs stxkxs commented Jun 7, 2026

Copy link
Copy Markdown
Member

What

Two consistency fixes from audit follow-up #29.

tags.go — nil-client guards on the original four auditors

The first four tag auditors (EC2, S3, RDS, Lambda) dereferenced their AWS client immediately, while the newer five (ECS/EKS/DynamoDB/SNS/SQS) open with if p.<client> == nil { return nil, nil }. A Provider with only some clients wired — how the per-service tests construct it — would panic in the first four once AuditTags dispatched with a required-tags list. Added the same guard to all four, plus TestAuditTags_NilClientsNoPanic driving the dispatch path with no clients wired (the existing no-required test returns before dispatch, so it never covered this).

k8s — compile-time interface assertion (not deletion)

Provider.Name() / Detect() look like dead code (callers use the concrete *k8s.Provider), but they're required by cloud.K8sRBACProvider — the interface the package is documented to implement. Deleting them would silently break that contract. Added var _ cloud.K8sRBACProvider = (*Provider)(nil) in rbac.go, mirroring AWS's var _ cloud.QuotaProvider = (*Provider)(nil) — documents intent and makes the compiler enforce the full method set against drift.

Issue point 3 (README servicequotas:ListServiceQuotas) was flagged as "no further action" — confirmed, nothing to change.

Verification

go build, go vet, go test ./..., golangci-lint run (0 issues), and the per-package coverage floors all pass locally.

Closes #29

…sert the k8s provider interface

Two consistency fixes from the core-repos audit.

─── tags.go: nil-client guards on the original four auditors ───
The first four tag auditors (EC2, S3, RDS, Lambda) dereferenced their AWS
client immediately, while the newer five (ECS, EKS, DynamoDB, SNS, SQS) added
in 7c open with an `if p.<client> == nil { return nil, nil }` guard. A Provider
built with only some clients wired — exactly how the per-service tests construct
it — would panic in the first four when `AuditTags` dispatched to them with a
required-tags list. Added the same guard to all four so partial construction is
safe, plus a `TestAuditTags_NilClientsNoPanic` regression test that drives the
dispatch path with no clients wired (the existing no-required test returns before
dispatch, so it never exercised this).

─── k8s: compile-time interface assertion ───
`Provider.Name()` and `Provider.Detect()` looked like dead code (callers use the
concrete `*k8s.Provider`, so nothing references them), but they're required by
`cloud.K8sRBACProvider` — the interface the package is documented to implement.
Deleting them would silently break that contract. Added
`var _ cloud.K8sRBACProvider = (*Provider)(nil)` in rbac.go, mirroring the AWS
provider's `var _ cloud.QuotaProvider = (*Provider)(nil)` — it documents the
intent and makes the compiler enforce the full method set (Name, Detect,
ContextName, ScanRBAC) against future drift.

`go build`, `go vet`, `go test ./...`, golangci-lint, and the per-package
coverage floors all pass.

Closes #29
@stxkxs stxkxs merged commit fb9a422 into main Jun 7, 2026
4 checks passed
@stxkxs stxkxs deleted the fix/k8s-interface-assertion-tags-nil-guard branch June 7, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit follow-up: dead code + missing nil-client guards

1 participant