File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,11 +60,26 @@ jobs:
6060 - name : Audit pod token automount
6161 shell : bash
6262 run : |
63+ # Covers workload controllers (Deployment/StatefulSet/DaemonSet),
64+ # ARC runner scale sets (AutoscalingRunnerSet — its pod spec lives at
65+ # .spec.template.spec, same as a Deployment), and bare Pods (whose
66+ # automount field is at .spec, not .spec.template.spec). Without ARC
67+ # + Pod the audit emits a false all-clear for exactly the runner pods
68+ # that most need a token-automount check.
69+ # $isPod below is a yq variable (not shell) — do not let the shell
70+ # expand it.
6371 # shellcheck disable=SC2016
6472 automounts=$(yq -N \
65- 'select((.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet")
66- and .spec.template.spec.automountServiceAccountToken != false)
67- | .metadata.name' \
73+ 'select(.kind == "Deployment" or .kind == "StatefulSet" or .kind == "DaemonSet"
74+ or .kind == "AutoscalingRunnerSet" or .kind == "Pod")
75+ | (.kind == "Pod") as $isPod
76+ | {"name": .metadata.name,
77+ "automount": (
78+ (select($isPod) | .spec.automountServiceAccountToken),
79+ (select($isPod == false) | .spec.template.spec.automountServiceAccountToken)
80+ )}
81+ | select(.automount != false)
82+ | .name' \
6883 /tmp/rendered.yaml | sort -u || true)
6984 {
7085 echo "### Pod Token Automount Audit"
You can’t perform that action at this time.
0 commit comments