Repository navigation
Add Slack notification workflow for PR events - #200
Conversation
Introduces a GitHub Actions workflow to send Slack notifications when a pull request is opened or marked ready for review by specific users. The workflow uses a Slack webhook and includes PR details in the notification payload.
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. Pull Request Developer GuidanceQuestions? See the Wiz FAQ. Please contact the Security Office if you encounter issues with Wiz PR scanning. |
| if: ${{ contains(fromJSON('["OS-miguelfreitas", "OS-joaomurgeiro", "osjlopes", "mvios", "OS-alexandretome", "rmb-guerra", "OS-rodrigolopes", "OS-thiagosiqueira", "OS-luisvendrame", "OS-josecunha"]'), github.event.pull_request.user.login) && !github.event.pull_request.draft }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: slackapi/slack-github-action@v2.0.0 | ||
| with: | ||
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| webhook-type: webhook-trigger | ||
| payload: | | ||
| pr_url: "${{ github.event.pull_request.html_url }}" | ||
| pr_number : "${{ github.event.pull_request.number }}" | ||
| pr_title: "${{ github.event.pull_request.title }}" | ||
| pr_user: "${{ github.event.pull_request.user.login }}" | ||
| pr_reviewers : "${{ join( github.event.pull_request.requested_reviewers.*.login , ' , ' ) }}" |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
In general, the fix is to explicitly set a restrictive permissions: block either at the workflow root or within the job so that GITHUB_TOKEN has only the minimal needed permissions. Since this workflow only reads pull request metadata (via github.event) and posts to Slack with a secret webhook, it does not need to use GITHUB_TOKEN at all. The safest configuration is to set permissions: {} at the workflow level (disabling all default permissions) or, if you prefer to keep minimal read access, use permissions: contents: read. Because the workflow doesn’t call the GitHub API via GITHUB_TOKEN, disabling all permissions is appropriate and does not change existing functionality.
Concretely, in .github/workflows/SlackNotification.yml, add a permissions: block near the top of the file, at the same indentation as on: and name:. This will apply to all jobs in the workflow, including slackNotification. No imports or additional methods are needed; this is purely a YAML configuration change. The best single change is:
name: Slack Notification
permissions: {}
on:
pull_request_target:
...This ensures that the GITHUB_TOKEN granted to the workflow has no repository permissions.
| @@ -1,5 +1,7 @@ | ||
| name: Slack Notification | ||
|
|
||
| permissions: {} | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: |
Introduces a GitHub Actions workflow to send Slack notifications when a pull request is opened or marked ready for review by specific users. The workflow uses a Slack webhook and includes PR details in the notification payload.
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests