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 6 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.

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
@@ -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  }}
EOF
@@ -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 }}
Copilot is powered by AI and may make mistakes. Always verify output.
Loading