Skip to content

Commit d444efb

Browse files
vdusekclaude
andcommitted
fix: Prevent script injection in workflow run blocks
Pass inputs and context values through env variables instead of direct ${{ }} interpolation in run: blocks. Affected workflows: - manual_version_docs.yaml (inputs.ref, default_branch, step outputs) - manual_regenerate_models.yaml (inputs.docs_workflow_run_id, github context) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 47f5a55 commit d444efb

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

.github/workflows/manual_regenerate_models.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ jobs:
4646
steps:
4747
- name: Validate inputs
4848
if: inputs.docs_pr_number || inputs.docs_workflow_run_id
49+
env:
50+
DOCS_WORKFLOW_RUN_ID: ${{ inputs.docs_workflow_run_id }}
4951
run: |
5052
if [[ -n "$DOCS_PR_NUMBER" ]] && ! [[ "$DOCS_PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
5153
echo "::error::docs_pr_number must be a positive integer, got: $DOCS_PR_NUMBER"
5254
exit 1
5355
fi
54-
if [[ -n "${{ inputs.docs_workflow_run_id }}" ]] && ! [[ "${{ inputs.docs_workflow_run_id }}" =~ ^[0-9]+$ ]]; then
55-
echo "::error::docs_workflow_run_id must be a numeric run ID, got: ${{ inputs.docs_workflow_run_id }}"
56+
if [[ -n "$DOCS_WORKFLOW_RUN_ID" ]] && ! [[ "$DOCS_WORKFLOW_RUN_ID" =~ ^[0-9]+$ ]]; then
57+
echo "::error::docs_workflow_run_id must be a numeric run ID, got: $DOCS_WORKFLOW_RUN_ID"
5658
exit 1
5759
fi
5860
@@ -173,5 +175,5 @@ jobs:
173175
run: |
174176
gh pr comment "$DOCS_PR_NUMBER" \
175177
--repo apify/apify-docs \
176-
--body "Python client model regeneration failed. [See workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})." \
178+
--body "Python client model regeneration failed. [See workflow run](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})." \
177179
|| echo "Warning: Failed to post failure comment to apify/apify-docs PR #$DOCS_PR_NUMBER."

.github/workflows/manual_version_docs.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ jobs:
4545
steps:
4646
- name: Determine checkout ref
4747
id: resolve_ref
48+
env:
49+
INPUT_REF: ${{ inputs.ref }}
50+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
4851
run: |
49-
REF="${{ inputs.ref }}"
50-
if [[ -z "$REF" ]]; then
51-
REF="${{ github.event.repository.default_branch }}"
52-
fi
52+
REF="${INPUT_REF:-$DEFAULT_BRANCH}"
5353
echo "ref=$REF" >> "$GITHUB_OUTPUT"
5454
5555
- name: Checkout repository
@@ -126,9 +126,7 @@ jobs:
126126

127127
- name: Resolve output commitish
128128
id: resolve_commitish
129+
env:
130+
COMMIT_SHA: ${{ steps.commit_versioned_docs.outputs.commit_long_sha }}
129131
run: |
130-
SHA="${{ steps.commit_versioned_docs.outputs.commit_long_sha }}"
131-
if [[ -z "$SHA" ]]; then
132-
SHA="$(git rev-parse HEAD)"
133-
fi
134-
echo "commitish=$SHA" >> "$GITHUB_OUTPUT"
132+
echo "commitish=${COMMIT_SHA:-$(git rev-parse HEAD)}" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)