Skip to content

Commit 76efd94

Browse files
committed
CI: fix template-injection findings in GitHub Actions workflows
zizmor flagged several workflow steps that expand untrusted `${{ }}` expressions directly into `run:` shell scripts. Route these values through `env:` instead so they're substituted as shell variables rather than interpolated into the script text.
1 parent c3236b9 commit 76efd94

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

.github/workflows/nightly-results.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: ${{ github.repository == 'php/php-src' && github.event.workflow_run.event == 'schedule' && github.event.workflow_run.conclusion == 'failure' }}
1212
steps:
13-
- run: |
13+
- env:
14+
RUN_URL: ${{ github.event.workflow_run.html_url }}
15+
SLACK_WEBHOOK: ${{ secrets.ACTION_MONITORING_SLACK }}
16+
run: |
1417
export DEBIAN_FRONTEND=noninteractive
1518
sudo apt-get install -y curl
16-
curl -X POST -H 'Content-type: application/json' --data '{"attachments": [{"text": "Job(s) in *nightly* failed", "footer": "<${{ github.event.workflow_run.html_url }}|View Run>", "color": "danger", "mrkdwn_in": ["text"]}]}' ${{ secrets.ACTION_MONITORING_SLACK }}
19+
curl -X POST -H 'Content-type: application/json' --data "$(printf '{"attachments": [{"text": "Job(s) in *nightly* failed", "footer": "<%s|View Run>", "color": "danger", "mrkdwn_in": ["text"]}]}' "$RUN_URL")" "$SLACK_WEBHOOK"

.github/workflows/test-suite.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,10 @@ jobs:
516516
exit $X
517517
- name: Test Laravel
518518
if: ${{ !cancelled() }}
519+
env:
520+
LARAVEL_VERSION: ${{ fromJson(inputs.branch).jobs.COMMUNITY.config.laravel_version }}
519521
run: |
520-
branch=${{ fromJson(inputs.branch).jobs.COMMUNITY.config.laravel_version }}
522+
branch="$LARAVEL_VERSION"
521523
git clone https://github.com/laravel/framework.git --depth=1 ${branch:+--branch="$branch"}
522524
cd framework
523525
git rev-parse HEAD
@@ -562,8 +564,10 @@ jobs:
562564
fi
563565
- name: Test Symfony
564566
if: ${{ !cancelled() }}
567+
env:
568+
SYMFONY_VERSION: ${{ fromJson(inputs.branch).jobs.COMMUNITY.config.symfony_version }}
565569
run: |
566-
branch=${{ fromJson(inputs.branch).jobs.COMMUNITY.config.symfony_version }}
570+
branch="$SYMFONY_VERSION"
567571
git clone https://github.com/symfony/symfony.git --depth=1 ${branch:+--branch="$branch"}
568572
cd symfony
569573
git rev-parse HEAD

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ jobs:
5858
nightly-
5959
- name: Generate Matrix
6060
id: set-matrix
61-
run: php .github/matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.event_name == 'pull_request' && github.ref || github.ref_name }}" '${{ toJSON(github.event.pull_request.labels) }}' "${{ github.repository }}"
61+
env:
62+
EVENT_NAME: ${{ github.event_name }}
63+
RUN_ATTEMPT: ${{ github.run_attempt }}
64+
REF: ${{ github.event_name == 'pull_request' && github.ref || github.ref_name }}
65+
PR_LABELS: ${{ toJSON(github.event.pull_request.labels) }}
66+
REPOSITORY: ${{ github.repository }}
67+
run: php .github/matrix.php "$EVENT_NAME" "$RUN_ATTEMPT" "$REF" "$PR_LABELS" "$REPOSITORY"
6268
TEST:
6369
needs: GENERATE_MATRIX
6470
if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}

.github/workflows/windows-builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
- name: Build
1919
env:
2020
GITHUB_TOKEN: ${{ secrets.WINDOWS_BUILDS_TOKEN }}
21+
TAG: ${{ inputs.tag || github.ref_name }}
2122
run: |
22-
TAG="${{ inputs.tag || github.ref_name }}"
2323
gh workflow run php.yml -R php/php-windows-builder -f php-version="${TAG#php-}"

0 commit comments

Comments
 (0)