Skip to content

Commit fa5c11d

Browse files
author
Jacek
committed
ci(repo): fix shell injection via env intermediaries, add ref allowlist validation
1 parent 958edb6 commit fa5c11d

1 file changed

Lines changed: 47 additions & 20 deletions

File tree

‎.github/workflows/e2e-staging.yml‎

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,36 @@ jobs:
5656
steps:
5757
- name: Normalize inputs
5858
id: inputs
59+
env:
60+
EVENT_NAME: ${{ github.event_name }}
61+
INPUT_REF: ${{ github.event.inputs.ref }}
62+
INPUT_COMMIT_SHA: ${{ github.event.inputs.clerk-go-commit-sha }}
63+
INPUT_NOTIFY_SLACK: ${{ github.event.inputs.notify-slack }}
64+
INPUT_SDK_SOURCE: ${{ github.event.inputs.sdk-source }}
65+
PAYLOAD_REF: ${{ github.event.client_payload.ref }}
66+
PAYLOAD_COMMIT_SHA: ${{ github.event.client_payload.clerk-go-commit-sha }}
67+
PAYLOAD_NOTIFY_SLACK: ${{ github.event.client_payload.notify-slack }}
68+
PAYLOAD_SDK_SOURCE: ${{ github.event.client_payload.sdk-source }}
5969
run: |
60-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
61-
echo "ref=${{ github.event.inputs.ref || 'main' }}" >> $GITHUB_OUTPUT
62-
echo "clerk-go-commit-sha=${{ github.event.inputs.clerk-go-commit-sha }}" >> $GITHUB_OUTPUT
63-
echo "notify-slack=${{ github.event.inputs.notify-slack }}" >> $GITHUB_OUTPUT
64-
echo "sdk-source=${{ github.event.inputs.sdk-source || 'latest' }}" >> $GITHUB_OUTPUT
70+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
71+
echo "ref=${INPUT_REF:-main}" >> $GITHUB_OUTPUT
72+
echo "clerk-go-commit-sha=$INPUT_COMMIT_SHA" >> $GITHUB_OUTPUT
73+
echo "notify-slack=$INPUT_NOTIFY_SLACK" >> $GITHUB_OUTPUT
74+
echo "sdk-source=${INPUT_SDK_SOURCE:-latest}" >> $GITHUB_OUTPUT
6575
else
66-
echo "ref=${{ github.event.client_payload.ref || 'main' }}" >> $GITHUB_OUTPUT
67-
echo "clerk-go-commit-sha=${{ github.event.client_payload.clerk-go-commit-sha || '' }}" >> $GITHUB_OUTPUT
68-
NOTIFY_SLACK="${{ github.event.client_payload.notify-slack }}"
69-
echo "notify-slack=${NOTIFY_SLACK:-true}" >> $GITHUB_OUTPUT
70-
echo "sdk-source=${{ github.event.client_payload.sdk-source || 'latest' }}" >> $GITHUB_OUTPUT
76+
echo "ref=${PAYLOAD_REF:-main}" >> $GITHUB_OUTPUT
77+
echo "clerk-go-commit-sha=${PAYLOAD_COMMIT_SHA:-}" >> $GITHUB_OUTPUT
78+
echo "notify-slack=${PAYLOAD_NOTIFY_SLACK:-true}" >> $GITHUB_OUTPUT
79+
echo "sdk-source=${PAYLOAD_SDK_SOURCE:-latest}" >> $GITHUB_OUTPUT
80+
fi
81+
82+
- name: Validate ref
83+
env:
84+
REF: ${{ steps.inputs.outputs.ref }}
85+
run: |
86+
if [[ ! "$REF" =~ ^(main|release/.*)$ ]]; then
87+
echo "::error::Ref '$REF' is not allowed. Only 'main' and 'release/*' branches are permitted."
88+
exit 1
7189
fi
7290
7391
- name: Checkout Repo
@@ -196,18 +214,27 @@ jobs:
196214
steps:
197215
- name: Normalize inputs
198216
id: inputs
217+
env:
218+
EVENT_NAME: ${{ github.event_name }}
219+
INPUT_REF: ${{ github.event.inputs.ref }}
220+
INPUT_COMMIT_SHA: ${{ github.event.inputs.clerk-go-commit-sha }}
221+
INPUT_NOTIFY_SLACK: ${{ github.event.inputs.notify-slack }}
222+
INPUT_SDK_SOURCE: ${{ github.event.inputs.sdk-source }}
223+
PAYLOAD_REF: ${{ github.event.client_payload.ref }}
224+
PAYLOAD_COMMIT_SHA: ${{ github.event.client_payload.clerk-go-commit-sha }}
225+
PAYLOAD_NOTIFY_SLACK: ${{ github.event.client_payload.notify-slack }}
226+
PAYLOAD_SDK_SOURCE: ${{ github.event.client_payload.sdk-source }}
199227
run: |
200-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
201-
echo "ref=${{ github.event.inputs.ref || 'main' }}" >> $GITHUB_OUTPUT
202-
echo "clerk-go-commit-sha=${{ github.event.inputs.clerk-go-commit-sha }}" >> $GITHUB_OUTPUT
203-
echo "notify-slack=${{ github.event.inputs.notify-slack }}" >> $GITHUB_OUTPUT
204-
echo "sdk-source=${{ github.event.inputs.sdk-source || 'latest' }}" >> $GITHUB_OUTPUT
228+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
229+
echo "ref=${INPUT_REF:-main}" >> $GITHUB_OUTPUT
230+
echo "clerk-go-commit-sha=$INPUT_COMMIT_SHA" >> $GITHUB_OUTPUT
231+
echo "notify-slack=$INPUT_NOTIFY_SLACK" >> $GITHUB_OUTPUT
232+
echo "sdk-source=${INPUT_SDK_SOURCE:-latest}" >> $GITHUB_OUTPUT
205233
else
206-
echo "ref=${{ github.event.client_payload.ref || 'main' }}" >> $GITHUB_OUTPUT
207-
echo "clerk-go-commit-sha=${{ github.event.client_payload.clerk-go-commit-sha || '' }}" >> $GITHUB_OUTPUT
208-
NOTIFY_SLACK="${{ github.event.client_payload.notify-slack }}"
209-
echo "notify-slack=${NOTIFY_SLACK:-true}" >> $GITHUB_OUTPUT
210-
echo "sdk-source=${{ github.event.client_payload.sdk-source || 'latest' }}" >> $GITHUB_OUTPUT
234+
echo "ref=${PAYLOAD_REF:-main}" >> $GITHUB_OUTPUT
235+
echo "clerk-go-commit-sha=${PAYLOAD_COMMIT_SHA:-}" >> $GITHUB_OUTPUT
236+
echo "notify-slack=${PAYLOAD_NOTIFY_SLACK:-true}" >> $GITHUB_OUTPUT
237+
echo "sdk-source=${PAYLOAD_SDK_SOURCE:-latest}" >> $GITHUB_OUTPUT
211238
fi
212239
213240
- name: Notify Slack on failure

0 commit comments

Comments
 (0)