Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@
types: [opened, assigned]
pull_request_review:
types: [submitted]
pull_request:
types: [review_requested]

jobs:
debug:
runs-on: ubuntu-latest
steps:
- name: Debug
run: |
echo "github.event: ${{ fromJSON(github.event) }}"

Check failure

Code scanning / CodeQL

Code injection Critical

Potential code injection in
${ fromJSON(github.event) }
, which may be controlled by an external user (
issue_comment
).
Potential code injection in
${ fromJSON(github.event) }
, which may be controlled by an external user (
pull_request_review_comment
).
Potential code injection in
${ fromJSON(github.event) }
, which may be controlled by an external user (
issues
).
Potential code injection in
${ fromJSON(github.event) }
, which may be controlled by an external user (
pull_request_review
).

Copilot Autofix

AI 10 days ago

To fix the code injection vulnerability, we should avoid direct interpolation of user-controlled values into shell commands. Specifically, instead of using echo "github.event: ${{ fromJSON(github.event) }}" directly, assign the value of ${{ toJSON(github.event) }} to an environment variable, then access it in the shell step using native shell variable expansion (e.g., "$EVENT"). This prevents any shell metacharacters in the event payload from being evaluated/executed by the shell.

  • Edit the debug job's step that currently echoes github.event using expression interpolation.
  • Move the event value assignment to an environment variable via the env: block.
  • Access that variable using $EVENT in the shell command, thus neutralizing code injection risks.
  • Use toJSON instead of fromJSON for proper string formatting (as in GitHub Actions best practices for dumping event payloads).

Suggested changeset 1
.github/workflows/claude.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml
--- a/.github/workflows/claude.yml
+++ b/.github/workflows/claude.yml
@@ -17,8 +17,10 @@
     runs-on: ubuntu-latest
     steps:
       - name: Debug
+        env:
+          EVENT: ${{ toJSON(github.event) }}
         run: |
-          echo "github.event: ${{ fromJSON(github.event) }}"
+          echo "github.event: $EVENT"
   claude:
     if: |
       (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
EOF
@@ -17,8 +17,10 @@
runs-on: ubuntu-latest
steps:
- name: Debug
env:
EVENT: ${{ toJSON(github.event) }}
run: |
echo "github.event: ${{ fromJSON(github.event) }}"
echo "github.event: $EVENT"
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
Copilot is powered by AI and may make mistakes. Always verify output.
claude:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) ||
(github.event_name == 'pull_request' && github.event.requested_user.name == 'pythonitaliabot2')
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
Expand All @@ -33,13 +42,14 @@

- name: Run Claude
uses: anthropics/claude-code-action@v1
if: ${{ github.event_name != 'pull_request' && github.event.requested_user.name != 'pythonitaliabot2' }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Optional: Customize the trigger phrase (default: @claude)
# trigger_phrase: "/claude"

# Optional: Trigger when specific user is assigned to an issue
assignee_trigger: "claude-bot"
assignee_trigger: "pythonitaliabot2"

# Optional: Configure Claude's behavior with CLI arguments
# claude_args: |
Expand All @@ -55,3 +65,10 @@
# "NODE_ENV": "test"
# }
# }

- name: Run code-review
uses: anthropics/claude-code-action@v1
if: ${{ github.event_name == 'pull_request' && github.event.requested_user.name == 'pythonitaliabot2' }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: "Review this PR"
Loading