Skip to content

Commit 4700970

Browse files
committed
fix: code injection via template expansion
https://docs.zizmor.sh/audits/#template-injection
1 parent af64d38 commit 4700970

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

.github/workflows/build-image.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ jobs:
3333
username: ${{ github.repository_owner }}
3434
password: ${{ secrets.GITHUB_TOKEN }}
3535
- name: Set tag for image
36+
env:
37+
REF_TYPE: ${{ github.ref_type }}
38+
REF_NAME: ${{ github.ref_name }}
3639
run: >-
3740
echo IMAGE_TAG=$(
38-
[ ${{ github.ref_type }} == 'tag' ]
39-
&& echo ${{ github.ref_name }}
41+
[ $REF_TYPE == 'tag' ]
42+
&& echo $REF_NAME
4043
|| echo 'latest'
4144
) >> $GITHUB_ENV
4245

.github/workflows/pre-commit.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ jobs:
2222
2323
- name: Get changed files
2424
id: file_changes
25+
env:
26+
BASE_REF: ${{ github.base_ref }}
27+
SHA: ${{ github.sha }}
2528
run: |
26-
export DIFF=$(git diff --name-only origin/${{ github.base_ref }} ${{
27-
github.sha
28-
}})
29-
echo "Diff between ${{ github.base_ref }} and ${{ github.sha }}"
29+
export DIFF=$(git diff --name-only origin/$BASE_REF $SHA)
30+
echo "Diff between $BASE_REF and $SHA"
3031
echo "files=$( echo "$DIFF" | xargs echo )" >> $GITHUB_OUTPUT
3132
3233
- name: Install shfmt

.github/workflows/reusable-tox.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ jobs:
150150
steps:
151151
- name: Export requested job-global environment variables
152152
if: inputs.environment-variables != ''
153+
env:
154+
INPUT_ENV_VARS: ${{ inputs.environment-variables }}
153155
run: >-
154-
echo '${{ inputs.environment-variables }}'
155-
>> "${GITHUB_ENV}"
156+
echo "$INPUT_ENV_VARS" >> $GITHUB_ENV
156157
157158
- name: >-
158159
Switch to using Python v${{ inputs.python-version }}
@@ -273,7 +274,7 @@ jobs:
273274
path: dist/
274275

275276
- name: >-
276-
Pre-populate tox envs: `${{ env.TOXENV }}`
277+
Pre-populate tox envs: $TOXENV
277278
run: >-
278279
python -Im
279280
tox
@@ -300,7 +301,7 @@ jobs:
300301
# But only for 'pytest' env in 'tox'.
301302
# For details: ../../tox.ini '[testenv:pytest]' 'commands_post'
302303
- name: >-
303-
Run tox envs: `${{ env.TOXENV }}`
304+
Run tox envs: $TOXENV
304305
id: tox-run
305306
run: >-
306307
python -Im
@@ -353,13 +354,15 @@ jobs:
353354
&& steps.tox-run.outputs.test-result-files == ''
354355
&& steps.tox-run.outputs.codecov-flags != 'MyPy'
355356
run: >-
356-
cat code-coverage-results.md >> "${GITHUB_STEP_SUMMARY}"
357+
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
357358
- name: Re-run the failing tests with maximum verbosity
358359
if: >-
359360
!cancelled()
360361
&& failure()
361362
&& inputs.tox-rerun-posargs != ''
362363
# `exit 1` makes sure that the job remains red with flaky runs
364+
env:
365+
INPUT_TOX_RERUN_POSARGS: ${{ inputs.tox-rerun-posargs }}
363366
run: >-
364367
python -Im
365368
tox
@@ -369,7 +372,7 @@ jobs:
369372
-vvvvv
370373
--skip-pkg-install
371374
--
372-
${{ inputs.tox-rerun-posargs }}
375+
$INPUT_TOX_RERUN_POSARGS
373376
&& exit 1
374377
shell: bash
375378
- name: Send coverage data to Codecov

0 commit comments

Comments
 (0)