compat/release: stop interpolating ${{ }} into run: bodies
CI / shell (shellcheck + syntax) (push) Successful in 8s
CI / python 3.11 (push) Successful in 13s
CI / python 3.12 (push) Successful in 15s
CI / python 3.13 (push) Successful in 15s
TrueNAS compatibility / compat (push) Successful in 9s

The report body is full of backticks, so 'echo "${{ steps.report.outputs.body }}"'
pasted it into the shell text and bash executed create-snapshot, def and async as
commands. The report is built from iX's middleware source, so that was an injection
vector as well as a bug. inputs.tag on workflow_dispatch had the same shape.

Data goes through files, scalars through env:. Tests enforce it across every
workflow.
This commit is contained in:
2026-07-13 17:30:50 +00:00
parent 9236aa0034
commit cd39489c7f
3 changed files with 171 additions and 50 deletions
+27 -6
View File
@@ -30,15 +30,30 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
# Via `env:`, never spliced into the script. `inputs.tag` is attacker-chosen on
# a workflow_dispatch, and a ${{ }} in a `run:` body is pasted into the shell
# TEXT -- a tag of `$(...)` would simply execute. env: is safe: the runner sets
# the variable instead of rewriting the script.
- name: Resolve tag
id: tag
env:
EVENT: ${{ github.event_name }}
INPUT_TAG: ${{ inputs.tag }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
if [ "$EVENT" = "workflow_dispatch" ]; then
tag="$INPUT_TAG"
else
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
tag="${GITHUB_REF#refs/tags/}"
fi
# Whatever it came from, it has to look like a tag we cut.
case "$tag" in
v[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "::error::refusing to release a tag that is not vX.Y.Z[-rcN]: $tag"; exit 1 ;;
esac
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
ref: ${{ steps.tag.outputs.tag }}
@@ -71,7 +86,9 @@ jobs:
# Catches the failure mode this repo actually had: VERSION= drifted to
# three different values across the scripts, and nothing noticed.
- name: "gate: version matches tag, CHANGELOG complete, nothing stranded"
run: python3 tools/release_notes.py check "${{ steps.tag.outputs.tag }}"
env:
TAG: ${{ steps.tag.outputs.tag }}
run: python3 tools/release_notes.py check "$TAG"
# THE BARRIER. A stable release must have been a release candidate on this
# exact commit. Candidates are invisible to users (update.sh and the alert
@@ -83,7 +100,9 @@ jobs:
# you find out. It is here because this is the only place that cannot be
# bypassed: it holds the token that publishes.
- name: "gate: this commit was a release candidate"
run: python3 tools/release_gate.py "${{ steps.tag.outputs.tag }}" -C .
env:
TAG: ${{ steps.tag.outputs.tag }}
run: python3 tools/release_gate.py "$TAG" -C .
# There is deliberately NO "did the candidate's CI run pass?" gate here.
#
@@ -98,8 +117,10 @@ jobs:
# that; it cannot verify it.
- name: extract release notes from CHANGELOG
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
python3 tools/release_notes.py notes "${{ steps.tag.outputs.tag }}" > /tmp/notes.md
python3 tools/release_notes.py notes "$TAG" > /tmp/notes.md
echo "--- release body ---"
cat /tmp/notes.md