Repository navigation
Hide built-in k8s principals in SMT output - #15
Merged
Merged
Conversation
ajwdev
added this pull request to stack #18
October 2, 2026 16:52
Clusters ship with platform principals (system:kube-controller-manager, the kube-system controller service accounts, eks:* and so on) that hold broad RBAC grants by design. They dominate `::smt cluster-admin`, `reaches` and `check_access` output without telling the operator anything about their own configuration. Add src/builtins.txt, a list of built-in Kubernetes and EKS principals (exact names plus `prefix*` patterns), and src/builtins.rs with `is_builtin`. SmtEncoder gains an `include_builtins` field (default false) that candidate-principal collection in check_access_invariant, check_namespace_isolation, check_reaches and direct_violations consults. Behavior change: built-in principals are now hidden by default from `::smt check_access`, `reaches`, `cluster-admin` and `check_isolation`. Pass `--all` to `::smt reaches` or `::smt cluster-admin` to include them. check_access and check_isolation have no flag and always hide them. Escalation paths are still computed through built-in intermediaries; only the listed principals are filtered. flake.nix gains jq and ast-grep, which the header of builtins.txt uses to regenerate the controller service account list from upstream controller_policy.go. Add unit tests for is_builtin and for the default-hidden versus include_builtins behavior on the testdata fixture. Make the test fixture temp dir unique per call so parallel tests do not delete each other's manifests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ajwdev
force-pushed
the
ajw-hide-builtin-principals
branch
from
October 2, 2026 16:56
df9e0d0 to
079bb10
Compare
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.
Summary
Hide built-in Kubernetes/EKS platform principals from SMT output by default.
src/builtins.txt: list of built-in principals (exact names andprefix*patterns):eks:*,system:kube-*users,system:nodesand friends, and the kube-system controller service accounts from upstreamcontroller_policy.go. Only upstream Kubernetes/EKS names; nothing environment specific.src/builtins.rs:is_builtin(principal).SmtEncoder.include_builtins(defaultfalse), consulted when collecting candidate principals incheck_access_invariant,check_namespace_isolation,check_reachesanddirect_violations.::smt reachesand::smt cluster-adminaccept--allto include built-ins; help and usage text updated.flake.nixaddsjqandast-grep, which the header ofbuiltins.txtuses to regenerate the controller list.Behavior change
Built-in principals are now hidden by default from
::smt check_access,reaches,cluster-adminandcheck_isolation.--allshows them forreachesandcluster-admin.check_accessandcheck_isolationhave no flag and always hide them. Escalation paths are still computed through built-in intermediaries (avia system:kube-controller-managerline can still appear); only the listed principals are filtered.Testing
New tests:
builtins::tests::*(exact, prefix, non-matches) andsmt::access::tests::builtin_principals_hidden_by_default_and_shown_with_include_builtins(testdata plus a CRB granting cluster-admin tosystem:kube-controller-manager). The access test helper's temp dir is now unique per call so parallel tests do not race.Before / after
Fixture is
testdata/plus one extra ClusterRoleBinding givingsystem:kube-controller-managercluster-admin. Before this change the output matches the--allrun.::smt cluster-admin(new default): 6 principals, controller-manager hidden.::smt cluster-admin --all: 7 principals, adds🤖 Generated with Claude Code