Harden the container checkout: no template expansion inside run
Build PCM package / build (push) Successful in 6s
tests / ubuntu-latest · py3.11 (push) Successful in 1m59s
tests / ubuntu-latest · py3.13 (push) Successful in 1m8s
tests / debian:12 (push) Successful in 53s
tests / archlinux:latest (push) Successful in 45s
tests / fedora:latest (push) Successful in 1m2s
tests / ubuntu:24.04 (push) Successful in 2m7s
tests / NixOS (FHS wrapper from docs/NIXOS.md) (push) Has been skipped
tests / macos-latest · py3.11 (push) Has been cancelled
tests / macos-latest · py3.13 (push) Has been cancelled
tests / windows-latest · py3.11 (push) Has been cancelled
tests / windows-latest · py3.13 (push) Has been cancelled
Build PCM package / build (push) Successful in 6s
tests / ubuntu-latest · py3.11 (push) Successful in 1m59s
tests / ubuntu-latest · py3.13 (push) Successful in 1m8s
tests / debian:12 (push) Successful in 53s
tests / archlinux:latest (push) Successful in 45s
tests / fedora:latest (push) Successful in 1m2s
tests / ubuntu:24.04 (push) Successful in 2m7s
tests / NixOS (FHS wrapper from docs/NIXOS.md) (push) Has been skipped
tests / macos-latest · py3.11 (push) Has been cancelled
tests / macos-latest · py3.13 (push) Has been cancelled
tests / windows-latest · py3.11 (push) Has been cancelled
tests / windows-latest · py3.13 (push) Has been cancelled
github.ref reaches the shell via env instead of ${{ }} interpolation
- a crafted PR branch name could otherwise inject commands into the
runner - and ref/sha formats are validated before git sees them.
This commit is contained in:
+14
-4
@@ -94,13 +94,23 @@ jobs:
|
||||
- name: Distro Qt runtime libraries + git
|
||||
run: ${{ matrix.setup }}
|
||||
# Plain-git checkout: works in any container with git alone.
|
||||
# (A private repo would need ${{ github.token }} on the URL.)
|
||||
# (A private repo would need github.token on the URL.) Values
|
||||
# arrive via env, not ${{ }} in the script: a template expansion
|
||||
# inside `run:` would let a crafted PR branch name inject shell
|
||||
# commands into the runner.
|
||||
- name: Checkout
|
||||
env:
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
REF: ${{ github.ref }}
|
||||
SHA: ${{ github.sha }}
|
||||
run: |
|
||||
case "$REF" in refs/heads/*|refs/tags/*|refs/pull/*) ;; *) echo "unexpected ref: $REF"; exit 1;; esac
|
||||
case "$SHA" in *[!0-9a-f]*|"") echo "unexpected sha"; exit 1;; esac
|
||||
git init -q .
|
||||
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
|
||||
git fetch -q --depth 50 origin "${{ github.ref }}"
|
||||
git checkout -q "${{ github.sha }}"
|
||||
git remote add origin "$SERVER_URL/$REPO.git"
|
||||
git fetch -q --depth 50 origin "$REF"
|
||||
git checkout -q "$SHA"
|
||||
- name: Install uv
|
||||
run: |
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
Reference in New Issue
Block a user