-
Notifications
You must be signed in to change notification settings - Fork 831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audit: strip etags from json output, fix bq access dump #2089
Conversation
/lgtm |
/hold |
Waiting for #2074 to merge so I can rebase on top of it and maybe update audit results before the next audit PR |
Do this by add a format_gcloud_json function, and passing all gcloud (or bq, gsutil) output through it. Format calls so the argument to use json output and the pass through the function are on the same line to make it clear this should be used everywhere json output is used. NOTE: in reformatting the `bq` calls to make this change, I switched away from prettyjson format, since jq will do the prettifying for us. However, this means that keys will be stored in a slightly different order than before.
/hold cancel diff --git a/audit/audit-gcp.sh b/audit/audit-gcp.sh
index 700077cb..d14f94e7 100755
--- a/audit/audit-gcp.sh
+++ b/audit/audit-gcp.sh
@@ -25,6 +25,7 @@ function format_gcloud_json() {
jq 'delpaths([path(..|.etag?|select(.))])'
}
+if false; then
echo "# Removing existing audit files"
rm -rf org_kubernetes.io
rm -rf projects
@@ -47,16 +48,20 @@ gcloud \
--format=json | format_gcloud_json \
> "org_kubernetes.io/iam.json"
+fi
echo "## Iterating over Projects"
gcloud \
projects list \
--filter="parent.id=${CNCF_GCP_ORG}" \
--format="value(name, projectNumber)" \
| sort \
+| grep -E '^(k8s-artifacts-prod|k8s-cip-test-prod|k8s-conform|k8s-gsuite|k8s-infra-e2e-scale-project|k8s-infra-ii-sandbox|k8s-infra-prow-build|k8s-infra-prow-build-trusted|k8s-infra-public-pii|kubernetes-public)' \
| while read -r PROJECT NUM; do
export CLOUDSDK_CORE_PROJECT="${PROJECT}"
echo "### Auditing Project ${PROJECT}"
+
+ rm -rf "projects/${PROJECT}"
mkdir -p "projects/${PROJECT}"
gcloud \ The list of projects was everything that had files under
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, spiffxp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes: #2029
Fixes: #2062
See commits for details
It's tough to test these out locally without hacking the script. I opted not to refactor into functions to allow for faster/easier testing as part of this PR, will save that for followup