R11DT-3590 Add Slack notification workflow for PR events#199
R11DT-3590 Add Slack notification workflow for PR events#199OS-miguelfreitas merged 1 commit intomasterfrom
Conversation
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 3 months ago
In general, the fix is to add an explicit permissions: block to the workflow (either at the root or at the job level) that grants only the minimal scopes required. This documents the intended access and prevents the workflow from gaining broader permissions if repository or organization defaults change or if the workflow is copied elsewhere.
For this specific workflow in .github/workflows/SlackNotification.yml, the job only reads PR data from the event payload and sends it to Slack via a secret webhook. It does not need to write to the repository, issues, or pull requests. The minimal sensible permissions are contents: read, pull-requests: read, and optionally packages: read (often included as part of a “read-only” baseline). We can set these at the workflow root so they apply to all jobs; since there is only one job (slackNotification), this is simple and does not alter behavior.
Concretely: edit .github/workflows/SlackNotification.yml and insert a permissions: section after the name: (or before jobs:) at the top level:
name: Slack Notification
on:
...
permissions:
contents: read
pull-requests: read
packages: read
jobs:
slackNotification:
...No additional imports, methods, or definitions are required; this is purely a YAML configuration change.
| @@ -5,6 +5,12 @@ | ||
| types: | ||
| - ready_for_review | ||
| - opened | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| packages: read | ||
|
|
||
| jobs: | ||
| slackNotification: | ||
| 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 }} |
This pull request introduces a new GitHub Actions workflow to automate Slack notifications when pull requests are created or marked as ready for review by specific users. The workflow ensures that only pull requests from a predefined list of users trigger the notification, and it excludes draft pull requests.
New Slack notification workflow:
.github/workflows/SlackNotification.ymlto send a Slack message via webhook when a pull request is opened or marked ready for review by selected users and is not a draft. The message includes the PR URL, number, title, author, and requested reviewers.Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests