Skip to content

Commit b62d907

Browse files
committed
fix: code injection via template expansion for inputs.tox-run-posargs
https://docs.zizmor.sh/audits/#dangerous-triggers
1 parent 3116c7d commit b62d907

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

.github/workflows/reusable-tox.yml

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,24 @@ jobs:
275275

276276
- name: >-
277277
Pre-populate tox envs: $TOXENV
278-
run: >-
279-
python -Im
280-
tox
281-
--parallel auto
282-
--parallel-live
283-
--skip-missing-interpreters false
284-
${{
285-
inputs.built-wheel-names != ''
286-
&& format('--installpkg dist/{0}', inputs.built-wheel-names)
287-
|| ''
288-
}}
289-
--notest
278+
shell: bash
279+
env:
280+
INPUT_BUILT_WHEEL_NAMES: ${{ inputs.built-wheel-names }}
281+
run: |-
282+
tox_common_args=(
283+
--parallel auto
284+
--parallel-live
285+
--skip-missing-interpreters false
286+
)
287+
if [ -n "$INPUT_BUILT_WHEEL_NAMES" ]; then
288+
python -Im tox "${tox_common_args[@]}" \
289+
--installpkg "dist/$INPUT_BUILT_WHEEL_NAMES" \
290+
--notest
291+
else
292+
python -Im tox "${tox_common_args[@]}" \
293+
--notest
294+
fi
295+
290296
- name: Initialize pre-commit envs if needed
291297
if: inputs.toxenv == 'pre-commit'
292298
run: >-
@@ -303,19 +309,24 @@ jobs:
303309
- name: >-
304310
Run tox envs: $TOXENV
305311
id: tox-run
306-
run: >-
307-
python -Im
308-
tox
309-
--parallel auto
310-
--parallel-live
311-
--skip-missing-interpreters false
312-
--skip-pkg-install
313-
--quiet
314-
${{
315-
inputs.tox-run-posargs != ''
316-
&& format('-- {0}', inputs.tox-run-posargs)
317-
|| ''
318-
}}
312+
shell: bash
313+
env:
314+
INPUT_TOX_RUN_POSARGS: ${{ inputs.tox-run-posargs }}
315+
run: |-
316+
tox_common_args=(
317+
--parallel auto
318+
--parallel-live
319+
--skip-missing-interpreters false
320+
--skip-pkg-install
321+
--quiet
322+
)
323+
if [ -n "$INPUT_TOX_RUN_POSARGS" ]; then
324+
python -Im tox "${tox_common_args[@]}" \
325+
-- "$INPUT_TOX_RUN_POSARGS"
326+
else
327+
python -Im tox "${tox_common_args[@]}"
328+
fi
329+
319330
# Generate nice SVG image of passed/failed tests in GHA Job Summary
320331
- name: Produce markdown test summary from JUnit
321332
if: >-

0 commit comments

Comments
 (0)