Last active
July 30, 2019 13:19
-
-
Save bgeesaman/ed4480d4eaf93e7e5c39ae8e5c4270c3 to your computer and use it in GitHub Desktop.
Enumerates GCP IAM Roles with the ability to view Legacy Auth Credentials on GKE Clusters.
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
#!/usr/bin/env bash | |
ALL_ROLES="$(gcloud iam roles list --format=json | jq -r '.[].name')" | |
for i in $ALL_ROLES; do | |
CURRENT_ROLE="${i}" | |
CURRENT_ROLE_PERMS="$(gcloud iam roles describe ${i} --format=json | jq -r '.includedPermissions[]?' | egrep 'container.clusters.get$|container.clusters.list')" | |
if [[ ! -z "${CURRENT_ROLE_PERMS}" ]]; then | |
echo "${CURRENT_ROLE} has: " | |
echo "${CURRENT_ROLE_PERMS}" | |
fi | |
CURRENT_ROLE_PERMS="" | |
done |
Author
bgeesaman
commented
Jul 23, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment