@@ -17,10 +17,16 @@ jobs:
1717 contains(github.event.comment.body, '/gemini-review')
1818 steps :
1919 - name : PR Info
20+ env :
21+ # Assign untrusted inputs to environment variables first
22+ COMMENT_BODY : ${{ github.event.comment.body }}
23+ ISSUE_NUM : ${{ github.event.issue.number }}
24+ REPO : ${{ github.repository }}
25+ # Use shell variables ("$VAR") instead of template tags
2026 run : |
21- echo "Comment: ${{ github.event.comment.body }} "
22- echo "Issue Number: ${{ github.event.issue.number }} "
23- echo "Repository: ${{ github.repository }} "
27+ echo "Comment: $COMMENT_BODY "
28+ echo "Issue Number: $ISSUE_NUM "
29+ echo "Repository: $REPO "
2430
2531 - name : Checkout Repo
2632 uses : actions/checkout@v3
@@ -30,17 +36,21 @@ jobs:
3036
3137 - name : Get PR Details
3238 id : pr
33- run : |
34- PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
35- echo "head_sha=$(echo $PR_JSON | jq -r .head.sha)" >> $GITHUB_OUTPUT
36- echo "base_sha=$(echo $PR_JSON | jq -r .base.sha)" >> $GITHUB_OUTPUT
3739 env :
3840 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41+ REPO : ${{ github.repository }}
42+ ISSUE_NUM : ${{ github.event.issue.number }}
43+
44+ # Use env vars for the API call to prevent injection
45+ # Use quotes around variables to prevent word splitting
46+ run : |
47+ PR_JSON=$(gh api "repos/$REPO/pulls/$ISSUE_NUM")
48+ echo "head_sha=$(echo "$PR_JSON" | jq -r .head.sha)" >> $GITHUB_OUTPUT
49+ echo "base_sha=$(echo "$PR_JSON" | jq -r .base.sha)" >> $GITHUB_OUTPUT
3950
4051 - uses : truongnh1992/gemini-ai-code-reviewer@main
4152 with :
4253 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4354 GEMINI_API_KEY : ${{ secrets.GEMINI_API_KEY }}
4455 GEMINI_MODEL : gemini-2.5-flash
45- EXCLUDE : " *.md,*.txt,package-lock.json"
46-
56+ EXCLUDE : " *.md,*.txt,package-lock.json"
0 commit comments