Created
November 8, 2024 03:55
-
-
Save daxmc99/e1504a9e7f386273cdf3e29d7ac602b0 to your computer and use it in GitHub Desktop.
one liner to list all roles & clusterroles that have secret access
This file contains 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
kubectl get roles,clusterroles -o json | jq -c ' | |
.items[] | |
| select(.rules != null) # Exclude entries with null rules | |
| select(.rules[].resources[] == "secrets") # Only resources with "secrets" access | |
| {name: .metadata.name, kind: .kind, namespace: .metadata.namespace, verbs: (.rules[].verbs | unique)}' \ | |
| jq -s 'unique_by(.name, .kind, .namespace)' # Deduplicate based on name, kind, and namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment