Skip to content

Commit cfb93ae

Browse files
committed
fix: remediate latest zizmor findings
The current version of Zizmor finds some potential template injection issues. We can fix these by indirecting via the `env`, or in one case by adding an ignore comment where we can't really fix it.
1 parent a5e8a34 commit cfb93ae

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

.github/workflows/test-get-vault-secrets.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ jobs:
6767
- name: Check secret value is ${{ matrix.instance }}
6868
if: matrix.instance != 'invalid'
6969
run: |
70-
if [[ "${{ env.INSTANCE }}" != "${{ matrix.instance }}" ]]; then
70+
if [[ "${INSTANCE}" != "${{ matrix.instance }}" ]]; then
7171
echo "Test failed: secret value does not match vault_instance input"
7272
exit 1
7373
fi
74+
env:
75+
INSTANCE: ${{ env.INSTANCE }}
7476

7577
- name: Ensure 'invalid' errored
7678
if: matrix.instance == 'invalid' && steps.test-vault-action.outcome != 'failure'

actions/build-push-to-dockerhub/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
> [!NOTE]
44
> If you are at Grafana Labs:
55
>
6-
> - A docker mirror is available on our self-hosted runners, see [the internal documentation](https://enghub.grafana-ops.net/docs/default/component/deployment-tools/platform/continuous-integration/#docker-caching-in-github-actions) for more info.
6+
> - A docker mirror is available on our self-hosted runners, see [the internal
7+
> documentation](https://enghub.grafana-ops.net/docs/default/component/deployment-tools/platform/continuous-integration/#docker-caching-in-github-actions)
8+
> for more info.
79
8-
This is a composite GitHub Action, used to build Docker images and push them to DockerHub.
9-
It uses `get-vault-secrets` action to get the DockerHub username and password from Vault.
10+
This is a composite GitHub Action, used to build Docker images and push them to
11+
DockerHub. It uses `get-vault-secrets` action to get the DockerHub username and
12+
password from Vault.
1013

1114
Example of how to use this action in a repository:
1215

@@ -64,4 +67,8 @@ jobs:
6467

6568
- If you specify `platforms` then the action will use buildx to build the image.
6669
- You must create a Dockerhub repo before you are able to push to it.
67-
- Most projects should be using Google Artifact Registry (instead of Dockerhub) to store their images. You can see more about that in the push-to-gar-docker shared workflow.
70+
- Most projects at Grafana Labs should be using Google Artifact Registry instead
71+
of Dockerhub to store their images. You can see more about that in the
72+
[push-to-gar-docker] shared workflow.
73+
74+
[push-to-gar-docker]: ../push-to-gar-docker/README.md

actions/build-push-to-dockerhub/action.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ runs:
103103
images: ${{ inputs.repository }}
104104
tags: ${{ inputs.tags }}
105105

106-
- name: Build and push Docker image
106+
# The `context` input is flagged by Zizmor as a [sink]. This means that with
107+
# the upstream action the user's input to the input ends up in an output,
108+
# and so if it's not handled properly, it could lead to a template injection
109+
# attack. In this action, we pass through the inputs, but we don't then pass
110+
# back the outputs, so we should be fine. Even if we did pass back the
111+
# outputs, we consider ourselves a proxy, so in that case our job would be
112+
# to warn users but not to take any action.
113+
#
114+
# [sink]: https://github.blog/security/application-security/how-to-secure-your-github-actions-workflows-with-codeql/#models
115+
- name: Build and push Docker image # zizmor: ignore[template-injection]
107116
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
108117
with:
109118
context: ${{ inputs.context }}

actions/login-to-gcs/action.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ runs:
7878
if: ${{ inputs.delete_credentials_file == 'true' && env.GOOGLE_APPLICATION_CREDENTIALS != '' }}
7979
shell: sh
8080
run: |
81-
if [ -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" ]; then
82-
rm -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
81+
if [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
82+
rm -f "${GOOGLE_APPLICATION_CREDENTIALS}"
8383
echo "::notice::Successfully deleted credentials file"
8484
else
85-
echo "::warning::Credentials file not found at ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
85+
echo "::warning::Credentials file not found at ${GOOGLE_APPLICATION_CREDENTIALS}"
8686
fi
87+
env:
88+
GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}

actions/push-to-gar-docker/action.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,11 @@ runs:
207207
if: ${{ inputs.delete_credentials_file == 'true' && env.GOOGLE_APPLICATION_CREDENTIALS != '' }}
208208
shell: sh
209209
run: |
210-
if [ -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" ]; then
211-
rm -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
210+
if [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
211+
rm -f "${GOOGLE_APPLICATION_CREDENTIALS}"
212212
echo "::notice::Successfully deleted credentials file"
213213
else
214-
echo "::warning::Credentials file not found at ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
214+
echo "::warning::Credentials file not found at ${GOOGLE_APPLICATION_CREDENTIALS}"
215215
fi
216+
env:
217+
GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}

actions/push-to-gcs/action.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ runs:
120120
if: ${{ inputs.delete_credentials_file == 'true' && env.GOOGLE_APPLICATION_CREDENTIALS != '' }}
121121
shell: sh
122122
run: |
123-
if [ -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" ]; then
124-
rm -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
123+
if [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
124+
rm -f "${GOOGLE_APPLICATION_CREDENTIALS}"
125125
echo "::notice::Successfully deleted credentials file"
126126
else
127-
echo "::warning::Credentials file not found at ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}"
127+
echo "::warning::Credentials file not found at ${GOOGLE_APPLICATION_CREDENTIALS}"
128128
fi
129+
env:
130+
GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}

0 commit comments

Comments
 (0)