Repository navigation
Commit 7a7c288
ci: pass matrix values to shell scripts through the environment
zizmor's `pedantic` persona reports six `template-injection`
findings, where `${{ matrix.project }}` and `${{ matrix.backend }}` are
expanded directly into `run:` scripts: three steps of the `test` job
in `dependencies.yml`, and the test step in `downstream.yml`.
These values are constants defined in the workflows' own matrices, so
nothing here is attacker-controllable. But template expansion inserts
text into the script before the shell parses it, so quotation marks
around a `${{ }}` expression do not neutralize quotation marks or
other shell syntax inside its value. A shell expansion of an
environment variable is not reparsed that way, so when it is double
quoted it is always a single word. Changing the style is also
preferable to turning off or suppressing the diagnostic, which would
then no longer catch an expansion that does carry untrusted data.
Pass each value through an environment variable named for its matrix
key in upper case (`PROJECT`, `BACKEND`), and expand it double quoted,
since neither word splitting nor pathname expansion is intended. Scope
each variable by how many steps use it: a value used by more than one
step goes in a job-level `env:` just before `steps:`, and a value used
by one step goes in that step's `env:`, just before `run:`. So
`PROJECT` is set for the whole `test` job in `dependencies.yml`, where
three steps use it, while `PROJECT` and `BACKEND` are set only for the
one step in `downstream.yml` that uses them. These are the naming,
quoting, and scoping conventions gitoxide adopted for the same
diagnostic.
The commands receive the same arguments as before. No file in this
repository reads `PROJECT` or `BACKEND`. `test/downstream/run.py`
passes most of its environment through to the downstream projects'
test suites, so they will also see these two variables, along with
the other variables already set in CI.
zizmor 1.31.1 at the `pedantic` level no longer reports any
`template-injection` findings. The only remaining finding is the
known `unpinned-images` finding for `alpine:latest`. `actionlint`
reports no problems with either workflow.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent e2d19ac commit 7a7c288
2 files changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | | - | |
| 43 | + | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
0 commit comments