Skip to content

Commit e96afb5

Browse files
committed
workflow
1 parent ebcef4c commit e96afb5

File tree

3 files changed

+61
-35
lines changed

3 files changed

+61
-35
lines changed

.github/actions/claude-code-action/action.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,29 @@ runs:
8686
- name: Extract GitHub Context and Create Prompt
8787
shell: bash
8888
id: prepare_context
89+
env:
90+
# Pass user-controlled inputs via environment variables to prevent script injection (GHSL-2025-093)
91+
EVENT_COMMENT_BODY: ${{ github.event.comment.body }}
92+
EVENT_ISSUE_TITLE: ${{ github.event.issue.title }}
93+
EVENT_ISSUE_BODY: ${{ github.event.issue.body }}
94+
EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
95+
EVENT_PR_TITLE: ${{ github.event.pull_request.title }}
96+
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
97+
EVENT_REVIEW_BODY: ${{ github.event.review.body }}
98+
EVENT_ASSIGNEE_LOGIN: ${{ github.event.assignee.login }}
99+
INPUT_TRIGGER_PHRASE: ${{ inputs.trigger_phrase }}
100+
INPUT_ASSIGNEE_TRIGGER: ${{ inputs.assignee_trigger }}
101+
INPUT_DIRECT_PROMPT: ${{ inputs.direct_prompt }}
102+
EVENT_ACTION: ${{ github.event.action }}
103+
EVENT_NAME: ${{ github.event_name }}
104+
REPO_NAME: ${{ github.repository }}
89105
run: |
90-
echo "🔍 Extracting GitHub context from event: ${{ github.event_name }}"
106+
echo "🔍 Extracting GitHub context from event: $EVENT_NAME"
91107
92108
# Function to check for trigger phrase
93109
check_trigger() {
94110
local text="$1"
95-
local trigger="${{ inputs.trigger_phrase }}"
111+
local trigger="$INPUT_TRIGGER_PHRASE"
96112
if [[ "$text" == *"$trigger"* ]]; then
97113
return 0
98114
fi
@@ -104,11 +120,11 @@ runs:
104120
USER_REQUEST=""
105121
CONTEXT_INFO=""
106122
107-
case "${{ github.event_name }}" in
123+
case "$EVENT_NAME" in
108124
"issue_comment")
109-
COMMENT_BODY="${{ github.event.comment.body }}"
110-
ISSUE_TITLE="${{ github.event.issue.title }}"
111-
ISSUE_NUMBER="${{ github.event.issue.number }}"
125+
COMMENT_BODY="$EVENT_COMMENT_BODY"
126+
ISSUE_TITLE="$EVENT_ISSUE_TITLE"
127+
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
112128
113129
if check_trigger "$COMMENT_BODY"; then
114130
TRIGGER_FOUND="true"
@@ -118,9 +134,9 @@ runs:
118134
;;
119135
120136
"pull_request_review_comment")
121-
COMMENT_BODY="${{ github.event.comment.body }}"
122-
PR_TITLE="${{ github.event.pull_request.title }}"
123-
PR_NUMBER="${{ github.event.pull_request.number }}"
137+
COMMENT_BODY="$EVENT_COMMENT_BODY"
138+
PR_TITLE="$EVENT_PR_TITLE"
139+
PR_NUMBER="$EVENT_PR_NUMBER"
124140
125141
if check_trigger "$COMMENT_BODY"; then
126142
TRIGGER_FOUND="true"
@@ -130,9 +146,9 @@ runs:
130146
;;
131147
132148
"pull_request_review")
133-
REVIEW_BODY="${{ github.event.review.body }}"
134-
PR_TITLE="${{ github.event.pull_request.title }}"
135-
PR_NUMBER="${{ github.event.pull_request.number }}"
149+
REVIEW_BODY="$EVENT_REVIEW_BODY"
150+
PR_TITLE="$EVENT_PR_TITLE"
151+
PR_NUMBER="$EVENT_PR_NUMBER"
136152
137153
if check_trigger "$REVIEW_BODY"; then
138154
TRIGGER_FOUND="true"
@@ -142,17 +158,17 @@ runs:
142158
;;
143159
144160
"issues")
145-
ISSUE_BODY="${{ github.event.issue.body }}"
146-
ISSUE_TITLE="${{ github.event.issue.title }}"
147-
ISSUE_NUMBER="${{ github.event.issue.number }}"
161+
ISSUE_BODY="$EVENT_ISSUE_BODY"
162+
ISSUE_TITLE="$EVENT_ISSUE_TITLE"
163+
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
148164
149165
if check_trigger "$ISSUE_TITLE" || check_trigger "$ISSUE_BODY"; then
150166
TRIGGER_FOUND="true"
151167
USER_REQUEST="$ISSUE_BODY"
152168
CONTEXT_INFO="Issue #$ISSUE_NUMBER: $ISSUE_TITLE"
153-
elif [[ "${{ github.event.action }}" == "assigned" && -n "${{ inputs.assignee_trigger }}" ]]; then
154-
ASSIGNEE="${{ github.event.assignee.login }}"
155-
if [[ "$ASSIGNEE" == "${{ inputs.assignee_trigger }}" ]]; then
169+
elif [[ "$EVENT_ACTION" == "assigned" && -n "$INPUT_ASSIGNEE_TRIGGER" ]]; then
170+
ASSIGNEE="$EVENT_ASSIGNEE_LOGIN"
171+
if [[ "$ASSIGNEE" == "$INPUT_ASSIGNEE_TRIGGER" ]]; then
156172
TRIGGER_FOUND="true"
157173
USER_REQUEST="$ISSUE_BODY"
158174
CONTEXT_INFO="Issue #$ISSUE_NUMBER assigned to $ASSIGNEE: $ISSUE_TITLE"
@@ -162,9 +178,9 @@ runs:
162178
esac
163179
164180
# Check for direct prompt override
165-
if [[ -n "${{ inputs.direct_prompt }}" ]]; then
181+
if [[ -n "$INPUT_DIRECT_PROMPT" ]]; then
166182
TRIGGER_FOUND="true"
167-
USER_REQUEST="${{ inputs.direct_prompt }}"
183+
USER_REQUEST="$INPUT_DIRECT_PROMPT"
168184
CONTEXT_INFO="Automated GitHub workflow"
169185
fi
170186
@@ -181,9 +197,9 @@ runs:
181197
cat > /tmp/claude-action/github-context-prompt.txt << EOF
182198
You are Claude Code, an AI assistant helping with GitHub workflows and code.
183199
184-
Repository: ${{ github.repository }}
200+
Repository: $REPO_NAME
185201
Context: $CONTEXT_INFO
186-
Event: ${{ github.event_name }}
202+
Event: $EVENT_NAME
187203
188204
User Request:
189205
$USER_REQUEST

.github/workflows/gemini-issue-review.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ jobs:
4646
id: issue_data
4747
env:
4848
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
49+
# Pass user-controlled inputs via environment variables to prevent script injection (GHSL-2025-093)
50+
EVENT_NAME: ${{ github.event_name }}
51+
EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
52+
EVENT_COMMENT_BODY: ${{ github.event.comment.body }}
4953
run: |
5054
# Get issue number from event or context
51-
if [ "${{ github.event_name }}" = "issue_comment" ]; then
52-
ISSUE_NUMBER="${{ github.event.issue.number }}"
53-
elif [ "${{ github.event_name }}" = "issues" ]; then
54-
ISSUE_NUMBER="${{ github.event.issue.number }}"
55+
if [ "$EVENT_NAME" = "issue_comment" ]; then
56+
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
57+
elif [ "$EVENT_NAME" = "issues" ]; then
58+
ISSUE_NUMBER="$EVENT_ISSUE_NUMBER"
5559
else
5660
echo "Unable to determine issue number"
5761
exit 1
@@ -62,8 +66,8 @@ jobs:
6266
6367
# Extract additional instructions from comment if triggered by comment
6468
ADDITIONAL_INSTRUCTIONS=""
65-
if [ "${{ github.event_name }}" = "issue_comment" ]; then
66-
COMMENT_BODY="${{ github.event.comment.body }}"
69+
if [ "$EVENT_NAME" = "issue_comment" ]; then
70+
COMMENT_BODY="$EVENT_COMMENT_BODY"
6771
ADDITIONAL_INSTRUCTIONS=$(echo "$COMMENT_BODY" | sed -n 's/.*@gemini[[:space:]]*\(.*\)/\1/p' | head -1)
6872
fi
6973

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,27 @@ jobs:
5555
id: get_pr
5656
env:
5757
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
58+
# Pass user-controlled inputs via environment variables to prevent script injection (GHSL-2025-093)
59+
EVENT_NAME: ${{ github.event_name }}
60+
EVENT_INPUTS_PR_NUMBER: ${{ github.event.inputs.pr_number }}
61+
EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
62+
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
63+
EVENT_COMMENT_BODY: ${{ github.event.comment.body }}
5864
run: |
59-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
60-
PR_NUMBER=${{ github.event.inputs.pr_number }}
61-
elif [ "${{ github.event_name }}" = "issue_comment" ]; then
62-
PR_NUMBER=${{ github.event.issue.number }}
65+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
66+
PR_NUMBER=$EVENT_INPUTS_PR_NUMBER
67+
elif [ "$EVENT_NAME" = "issue_comment" ]; then
68+
PR_NUMBER=$EVENT_ISSUE_NUMBER
6369
else
64-
PR_NUMBER=${{ github.event.pull_request.number }}
70+
PR_NUMBER=$EVENT_PR_NUMBER
6571
fi
6672
6773
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
6874
6975
# Extract additional instructions from comment (if triggered by comment)
7076
ADDITIONAL_INSTRUCTIONS=""
71-
if [ "${{ github.event_name }}" = "issue_comment" ]; then
72-
COMMENT_BODY="${{ github.event.comment.body }}"
77+
if [ "$EVENT_NAME" = "issue_comment" ]; then
78+
COMMENT_BODY="$EVENT_COMMENT_BODY"
7379
ADDITIONAL_INSTRUCTIONS=$(echo "$COMMENT_BODY" | sed 's/.*@gemini//' | xargs)
7480
fi
7581
echo "additional_instructions=$ADDITIONAL_INSTRUCTIONS" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)