Skip to content

Conversation

@xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Oct 23, 2025

Description

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

Comment on lines +10 to +59
runs-on: ubuntu-latest
steps:
- name: Check if the comment contains the run command
id: check_comment
run: |
commands=echo '${{ github.event.comment.body }}' | grep -oPz '```run_this\n(just .*\n)*```\n' |
- uses: actions/checkout@v3
if: steps.check_comment.outputs.commands != ''
- name: Install toolchain
if: steps.check_comment.outputs.commands != ''
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
if: steps.check_comment.outputs.commands != ''
with:
cache-provider: "warpbuild"
- name: Install just
if: steps.check_comment.outputs.commands != ''
run: cargo install just
- name: Execute the commands
if: steps.check_comment.outputs.commands != ''
id: execute_commands
run: |
echo "${{ steps.check_comment.outputs.commands }}" | while read line; do
echo "[$line]"
if [ "$line" = "\`\`\`run_this" ]; then
OUTPUT=""
elif [[ "$line" = "\`\`\`" ]]; then
echo "Results:"
echo "\`\`\`"
echo "$OUTPUT"
echo "\`\`\`"
else
NEWOUTPUT=$(bash -c "$line" 2>&1)
OUTPUT="$OUTPUT $NEWOUTPUT"
fi
done
- name: Create commit comment
if: steps.check_comment.outputs.commands != ''
uses: peter-evans/commit-comment@v4
with:
body: |
Running:
${{ steps.check_comment.outputs.commands }}

Results:
```
${{ steps.execute_commands.outputs.OUTPUT }}
```

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: {contents: read}

Copilot Autofix

AI 21 days ago

The best way to fix this issue is to explicitly set a permissions block within the workflow (either globally or just for this job) that grants only the required privileges. For this workflow, the main requirements are:

  • Read access to repository contents for checkout.
  • Ability to write commit comments (for peter-evans/commit-comment@v4 action), which requires contents: write (since commit comments are part of code, not issue comments).
  • All other scopes should remain unset for least privilege.

The most conservative recommendation is to add the following block at the same level as jobs:, above jobs::

permissions:
  contents: write

Alternatively, if you wish to restrict permissions further and only give write at the job level (not globally), you can add the permissions: block under jobs.process_comment:, but the global fix is typical.

Action: Insert the following block between line 2 and line 3 in the .github/workflows/pr-automation.yml file:

permissions:
  contents: write

No additional imports or definitions are required for YAML workflows.

Suggested changeset 1
.github/workflows/pr-automation.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/pr-automation.yml b/.github/workflows/pr-automation.yml
--- a/.github/workflows/pr-automation.yml
+++ b/.github/workflows/pr-automation.yml
@@ -1,5 +1,7 @@
 name: Run Command on Comment
 
+permissions:
+  contents: write
 on:
   issue_comment:
     types:
EOF
@@ -1,5 +1,7 @@
name: Run Command on Comment

permissions:
contents: write
on:
issue_comment:
types:
Copilot is powered by AI and may make mistakes. Always verify output.
- name: Check if the comment contains the run command
id: check_comment
run: |
commands=echo '${{ github.event.comment.body }}' | grep -oPz '```run_this\n(just .*\n)*```\n' |

Check failure

Code scanning / CodeQL

Code injection Critical

Potential code injection in
${ github.event.comment.body }
, which may be controlled by an external user (
issue_comment
).

Copilot Autofix

AI 21 days ago

How to fix:
Replace the direct interpolation of ${{ github.event.comment.body }} into the shell command with safe usage via environment variables.

Detailed fix:
At the start of the step where we use ${{ github.event.comment.body }}, add an env: block to assign its value to an environment variable, e.g., COMMENT_BODY. Then, in the run: command, reference the value with proper shell variable syntax ("$COMMENT_BODY"). This allows the shell to safely parse the value regardless of its content and prevents opportunity for code injection or unintended expansion.

Concrete changes:

  • On step 13-15, add an env: field to assign COMMENT_BODY: ${{ github.event.comment.body }}.
  • In the script on line 15, replace echo '${{ github.event.comment.body }}' with echo "$COMMENT_BODY".
  • No new imports or actions are needed.

Suggested changeset 1
.github/workflows/pr-automation.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/pr-automation.yml b/.github/workflows/pr-automation.yml
--- a/.github/workflows/pr-automation.yml
+++ b/.github/workflows/pr-automation.yml
@@ -11,8 +11,10 @@
     steps:
       - name: Check if the comment contains the run command
         id: check_comment
+        env:
+          COMMENT_BODY: ${{ github.event.comment.body }}
         run: |
-          commands=echo '${{ github.event.comment.body }}' | grep -oPz '```run_this\n(just .*\n)*```\n' | 
+          commands=$(echo "$COMMENT_BODY" | grep -oPz '```run_this\n(just .*\n)*```\n')
       - uses: actions/checkout@v3
         if: steps.check_comment.outputs.commands != ''
       - name: Install toolchain
EOF
@@ -11,8 +11,10 @@
steps:
- name: Check if the comment contains the run command
id: check_comment
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
commands=echo '${{ github.event.comment.body }}' | grep -oPz '```run_this\n(just .*\n)*```\n' |
commands=$(echo "$COMMENT_BODY" | grep -oPz '```run_this\n(just .*\n)*```\n')
- uses: actions/checkout@v3
if: steps.check_comment.outputs.commands != ''
- name: Install toolchain
Copilot is powered by AI and may make mistakes. Always verify output.
@xunilrj xunilrj self-assigned this Oct 23, 2025
@xunilrj xunilrj marked this pull request as ready for review October 23, 2025 14:45
@xunilrj xunilrj requested a review from a team as a code owner October 23, 2025 14:45
@xunilrj
Copy link
Contributor Author

xunilrj commented Oct 23, 2025

just pe2e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants