Skip to content

Commit 8db6284

Browse files
committed
Improve security hardening
1 parent 2619cee commit 8db6284

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

.github/workflows/devflow-pr-review.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,33 @@ jobs:
3838
- name: Resolve PR metadata
3939
id: pr
4040
shell: bash
41+
env:
42+
PR_HTML_URL: ${{ github.event.pull_request.html_url }}
43+
PR_NUMBER: ${{ github.event.pull_request.number }}
44+
PR_URL_INPUT: ${{ inputs.pr_url }}
4145
run: |
4246
set -euo pipefail
4347
4448
if [[ "${GITHUB_EVENT_NAME}" == "pull_request_target" ]]; then
45-
echo "pr_url=${{ github.event.pull_request.html_url }}" >> "$GITHUB_OUTPUT"
46-
echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
47-
echo "repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
49+
echo "pr_url=${PR_HTML_URL}" >> "$GITHUB_OUTPUT"
50+
echo "pr_number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
51+
echo "repo=${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
4852
exit 0
4953
fi
5054
51-
pr_url="${{ inputs.pr_url }}"
52-
if [[ -z "$pr_url" ]]; then
55+
if [[ -z "$PR_URL_INPUT" ]]; then
5356
echo "workflow_dispatch requires pr_url" >&2
5457
exit 1
5558
fi
5659
57-
if [[ ! "$pr_url" =~ /pull/([0-9]+)$ ]]; then
58-
echo "Could not parse pull request number from: $pr_url" >&2
60+
if [[ ! "$PR_URL_INPUT" =~ /pull/([0-9]+)$ ]]; then
61+
echo "Could not parse pull request number from: $PR_URL_INPUT" >&2
5962
exit 1
6063
fi
6164
62-
echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT"
65+
echo "pr_url=${PR_URL_INPUT}" >> "$GITHUB_OUTPUT"
6366
echo "pr_number=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
64-
echo "repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
67+
echo "repo=${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
6568
6669
# Safe checkout: base repo only, not the untrusted PR head.
6770
- name: Checkout target repo base
@@ -105,18 +108,22 @@ jobs:
105108
GH_COPILOT_TOKEN: ${{ secrets.GH_COPILOT_TOKEN }}
106109
SK_REPO_PATH: ${{ env.TARGET_REPO_PATH }}
107110
AGENT_REPO_PATH: ${{ env.TARGET_REPO_PATH }}
111+
PR_REPO: ${{ steps.pr.outputs.repo }}
112+
PR_NUMBER: ${{ steps.pr.outputs.pr_number }}
108113
run: |
109114
uv run python scripts/classify_pr_spam.py \
110-
--repo "${{ steps.pr.outputs.repo }}" \
111-
--pr-number "${{ steps.pr.outputs.pr_number }}" \
115+
--repo "$PR_REPO" \
116+
--pr-number "$PR_NUMBER" \
112117
--repo-path "${TARGET_REPO_PATH}" \
113118
--apply-labels
114119
115120
- name: Stop after spam gate
116121
if: ${{ steps.spam.outputs.decision != 'allow' }}
117122
shell: bash
123+
env:
124+
SPAM_DECISION: ${{ steps.spam.outputs.decision }}
118125
run: |
119-
echo "Skipping review because spam gate decided: ${{ steps.spam.outputs.decision }}"
126+
echo "Skipping review because spam gate decided: ${SPAM_DECISION}"
120127
121128
- name: Run PR review
122129
if: ${{ steps.spam.outputs.decision == 'allow' }}
@@ -127,8 +134,9 @@ jobs:
127134
GH_COPILOT_TOKEN: ${{ secrets.GH_COPILOT_TOKEN }}
128135
SK_REPO_PATH: ${{ env.TARGET_REPO_PATH }}
129136
AGENT_REPO_PATH: ${{ env.TARGET_REPO_PATH }}
137+
PR_URL: ${{ steps.pr.outputs.pr_url }}
130138
run: |
131139
uv run python scripts/trigger_pr_review.py \
132-
--pr-url "${{ steps.pr.outputs.pr_url }}" \
133-
--github-username "${{ github.actor }}" \
140+
--pr-url "$PR_URL" \
141+
--github-username "$GITHUB_ACTOR" \
134142
--no-require-comment-selection

0 commit comments

Comments
 (0)