Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALCS-2227: Configure dependabot #2169

Closed

Conversation

dylanrogowsky-oxd
Copy link
Collaborator

No description provided.

Comment on lines +25 to +35
run: |
# Get PR number from branch name
PR_NUMBER=$(echo ${{ github.event.workflow_run.head_branch }} | grep -o '[0-9]\+' || echo '')

if [ -n "$PR_NUMBER" ]; then
# Approve PR
gh pr review $PR_NUMBER --approve

# Enable auto-merge
gh pr merge $PR_NUMBER --auto --merge
fi

Check failure

Code scanning / CodeQL

Expression injection in Actions Critical

Potential injection from the ${{ github.event.workflow_run.head_branch }}, which may be controlled by an external user.

Copilot Autofix AI 13 days ago

To fix the problem, we need to avoid using the untrusted input value directly in the shell command. Instead, we should set the untrusted input value to an intermediate environment variable and then use the environment variable using the native syntax of the shell. This approach prevents the injection vulnerability by ensuring that the value is treated as a plain string rather than being interpreted as part of the shell command.

Specifically, we will:

  1. Set the PR_NUMBER value to an environment variable.
  2. Use the environment variable in the shell command.
Suggested changeset 1
.github/workflows/auto-merge-dependabot.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/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml
--- a/.github/workflows/auto-merge-dependabot.yml
+++ b/.github/workflows/auto-merge-dependabot.yml
@@ -24,5 +24,8 @@
       - name: Auto-merge Dependabot PR
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
         run: |
           # Get PR number from branch name
-          PR_NUMBER=$(echo ${{ github.event.workflow_run.head_branch }} | grep -o '[0-9]\+' || echo '')
+          PR_NUMBER=$(echo "$HEAD_BRANCH" | grep -o '[0-9]\+' || echo '')
           
@@ -30,8 +33,5 @@
             # Approve PR
-            gh pr review $PR_NUMBER --approve
+            gh pr review "$PR_NUMBER" --approve
             
             # Enable auto-merge
-            gh pr merge $PR_NUMBER --auto --merge
-          fi
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
+            gh pr merge "$PR_NUMBER" --auto --merge
\ No newline at end of file
EOF
@@ -24,5 +24,8 @@
- name: Auto-merge Dependabot PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
# Get PR number from branch name
PR_NUMBER=$(echo ${{ github.event.workflow_run.head_branch }} | grep -o '[0-9]\+' || echo '')
PR_NUMBER=$(echo "$HEAD_BRANCH" | grep -o '[0-9]\+' || echo '')

@@ -30,8 +33,5 @@
# Approve PR
gh pr review $PR_NUMBER --approve
gh pr review "$PR_NUMBER" --approve

# Enable auto-merge
gh pr merge $PR_NUMBER --auto --merge
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
gh pr merge "$PR_NUMBER" --auto --merge
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

1 participant