feat: platform audit — AWS-side IRSA role conformance#9
Merged
Conversation
Extends the Platform-tenant auditor with the AWS half of the contract: it
now verifies the per-tenant IRSA role behind Platform.status.iamRoleArn,
not just the cluster resources. Read-only; needs AWS credentials.
─── IRSA conformance ───
- internal/cloud/aws: GetRoleInfo reads a role's ARN, URL-decoded trust
policy, tags, attached managed-policy ARNs, and inline-policy names via
the IAM API (NoSuchEntity -> not found). Satisfies platform.RoleReader.
- internal/platform: Audit now takes a RoleReader (nil skips the AWS
checks). For each Ready/Suspended platform with a status.iamRoleArn it
flags:
- role missing (status points at a non-existent role)
- trust policy not constrained to
system:serviceaccount:<ns>:tenant-runtime
- inline policies present (the contract is managed-policy-only)
- declared spec.identity.extraPolicyArns not attached
- suspension tag (platform.nanohype.dev/suspended) disagreeing with
status.suspendedAt
- no managed policies attached on an active tenant (baseline expected)
- internal/cloud: IAMRoleInfo plus the six IRSA finding types.
─── Wiring ───
- cmd/platform.go and the platform_audit MCP tool build the role-reader
from the default AWS credential chain; when creds are absent the IRSA
checks are skipped (with a note) so the k8s-side audit still runs.
- SARIF platform rules extended with the new finding types.
─── Tests ───
- audit_test.go: a fake RoleReader covers role-missing, drift (inline +
trust mismatch + no-baseline), and fully-conformant role cases; the
existing k8s-only tests pass a nil reader.
No new dependency — reuses aws-sdk-go-v2 IAM. Verification: go build ./...,
go test ./..., go vet ./..., and golangci-lint v2.12.2 (uncapped) all pass.
Co-authored-by: stxkxsbot <275011021+stxkxsbot@users.noreply.github.com>
stxkxs
added a commit
that referenced
this pull request
May 30, 2026
…I group Completes the Platform-tenant auditor with the budget + compliance cross-resource checks, and corrects the custom-resource API group that slices #8/#9 hardcoded wrong. ─── Bug fix (affects the already-merged auditor) ─── The Platform and Tenant CRs live in the platform.nanohype.dev API group and BudgetPolicy in governance.nanohype.dev — NOT agents.stxkxs.io, which the auditor's platformGVR hardcoded. Against a real cluster, `platform audit` listed zero Platforms (the GVR matched nothing). Corrected platformGVR and added the tenant + budget GVRs. The earlier unit tests passed only because their fixtures used the same wrong group; the fixtures now use the real groups, so they actually exercise the shipping GVR. ─── Budget + compliance cross-references ─── - internal/platform: auditBudgetCompliance runs for every Platform (spec consistency, independent of phase) and reports: - spec.budget.name empty or pointing at a BudgetPolicy that doesn't exist (BUDGET_POLICY_MISSING) - a SOC2 platform whose referenced BudgetPolicy has killSwitchEnabled=false (KILL_SWITCH_DISABLED) - a Platform less strict than its owning Tenant — Tenant requires soc2/hipaa but the Platform doesn't (COMPLIANCE_WEAKER_THAN_TENANT) - spec.tenant pointing at a Tenant CR that doesn't exist (TENANT_MISSING) BudgetPolicy is looked up in the Platform's namespace; the Tenant CR is cluster-scoped. Reuses the dynamic client already threaded through Audit. - internal/cloud: the four new finding types; SARIF rules extended. ─── Tests ─── - audit_test.go: fixtures corrected to the real API groups and given a matching BudgetPolicy + Tenant; new cases cover budget-missing, kill-switch-disabled, and compliance-weaker-than-tenant (10 tests total). No new dependency. Verification: go build ./..., go test ./..., go vet ./..., and golangci-lint v2.12.2 (uncapped) all pass. This completes Phase 2: the Platform auditor now spans the cluster, AWS IRSA, and budget/compliance sides of the eks-agent-platform contract. Co-authored-by: stxkxsbot <275011021+stxkxsbot@users.noreply.github.com>
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.
See the commit message for full detail. Second slice of the Platform-tenant auditor (the K8s side landed in #8) — adds the AWS half of the contract.
Summary
status.iamRoleArn, verifies the IAM role exists, trusts onlysystem:serviceaccount:<ns>:tenant-runtime, has no inline policies, carries the declaredextraPolicyArns, has a suspension tag consistent withstatus.suspendedAt, and (when active) has a baseline managed policy attached.aws.GetRoleInfo(newplatform.RoleReader);Audittakes a role-reader (nil = skip AWS checks). The command +platform_auditMCP tool build it from the AWS credential chain and degrade gracefully (k8s-side audit still runs) when creds are absent.Verification
go build,go test ./...,go vet, golangci-lint v2.12.2 (uncapped) all pass.Remaining (slice 3)
Budget + compliance CR cross-refs:
spec.budget.nameresolves to a BudgetPolicy, SOC2 → kill-switch enabled, and Platform ≤ Tenant compliance strictness (needs the governance-group BudgetPolicy/Tenant GVRs).