Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/SlackNotification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Slack Notification

on:
pull_request_target:
types:
- ready_for_review
- opened
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 }}
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 , ' , ' ) }}"
Comment on lines +10 to +22

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

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.

Suggested changeset 1
.github/workflows/SlackNotification.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/SlackNotification.yml b/.github/workflows/SlackNotification.yml
--- a/.github/workflows/SlackNotification.yml
+++ b/.github/workflows/SlackNotification.yml
@@ -1,5 +1,7 @@
 name: Slack Notification
 
+permissions: {}
+
 on: 
   pull_request_target:
     types:
EOF
@@ -1,5 +1,7 @@
name: Slack Notification

permissions: {}

on:
pull_request_target:
types:
Copilot is powered by AI and may make mistakes. Always verify output.