Skip to content

Conversation

@rishav-karanjit
Copy link
Member

Issue #, if available:

Description of changes:

Adding slacking notification on daily CI failure and issue creation.

Similar PR in DB-ESDK: aws/aws-database-encryption-sdk-dynamodb#1964

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

@rishav-karanjit rishav-karanjit requested a review from a team as a code owner January 9, 2026 18:30
Comment on lines +42 to +56
notify:
needs:
[
codebuild_batch,
codebuild_tests,
decrypt_oracle,
static_analysis,
test_vector_handler,
tests
]
if: ${{ failure() }}
uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main
with:
message: "Daily CI failed on `${{ github.repository }}`. View run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
secrets:

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 1 day ago

In general, the fix is to add an explicit permissions block to the workflow (at the root level, or per job) to restrict the GITHUB_TOKEN to the minimal access necessary. Root-level permissions act as defaults for all jobs that do not override them, which is appropriate here since none of the shown jobs declare their own permissions.

The safest change without altering existing functionality is to add a root-level permissions block just after the name: Daily CI line, setting contents: read. This is the minimal common permission needed for typical CI workflows (e.g., to fetch the repo). If any of the called reusable workflows require additional scopes (such as pull-requests: write for status updates), they should define those themselves; adding contents: read at the root will not block that. The notify job appears to send a Slack message using a secret and should not need elevated GITHUB_TOKEN scopes, so the root-level contents: read is appropriate.

Concretely, in .github/workflows/daily_ci.yml, insert:

permissions:
  contents: read

between lines 2 and 4. No imports or additional definitions are required, as this is purely YAML configuration within GitHub Actions.

Suggested changeset 1
.github/workflows/daily_ci.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/daily_ci.yml b/.github/workflows/daily_ci.yml
--- a/.github/workflows/daily_ci.yml
+++ b/.github/workflows/daily_ci.yml
@@ -1,6 +1,9 @@
 # This workflow runs every weekday at 15:00 UTC (8AM PDT)
 name: Daily CI
 
+permissions:
+  contents: read
+
 on:
   schedule:
     - cron: "00 15 * * 1-5"
EOF
@@ -1,6 +1,9 @@
# This workflow runs every weekday at 15:00 UTC (8AM PDT)
name: Daily CI

permissions:
contents: read

on:
schedule:
- cron: "00 15 * * 1-5"
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +10 to +17
if: github.event_name == 'issues'
uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main
with:
message: "New github issue `${{ github.event.issue.title }}`. Link: ${{ github.event.issue.html_url }}"
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_GHI }}

notify-comment:

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 1 day ago

In general, the fix is to explicitly declare a permissions block in the workflow (at the top level, since neither job has its own) and restrict the default GITHUB_TOKEN permissions to the minimum necessary. This workflow only reacts to issues and issue_comment events and passes data plus a secret to a reusable Slack notification workflow; it doesn’t change repository contents or metadata itself. Therefore, the minimal safe default is contents: read, which allows basic read operations if needed while avoiding unnecessary write scopes.

The best fix without changing existing functionality is to add a top-level permissions block between the on: section and the jobs: section in .github/workflows/issue-notification.yml. Set contents: read as a conservative, least-privilege permission; if the reusable workflow needs something more, it can declare its own permissions in its own file, but that is outside the scope of this snippet. No imports or additional methods are needed, since this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/issue-notification.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/issue-notification.yml b/.github/workflows/issue-notification.yml
--- a/.github/workflows/issue-notification.yml
+++ b/.github/workflows/issue-notification.yml
@@ -5,6 +5,9 @@
   issue_comment:
     types: [created]
 
+permissions:
+  contents: read
+
 jobs:
   notify-issue:
     if: github.event_name == 'issues'
EOF
@@ -5,6 +5,9 @@
issue_comment:
types: [created]

permissions:
contents: read

jobs:
notify-issue:
if: github.event_name == 'issues'
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +18 to +23
if: github.event_name == 'issue_comment' && !github.event.issue.pull_request
uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main
with:
message: "New comment on issue `${{ github.event.issue.title }}`. Link: ${{ github.event.comment.html_url }}"
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_GHI }} No newline at end of file

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 1 day ago

In general, this issue is fixed by explicitly defining a permissions: block for the workflow or individual jobs, restricting the GITHUB_TOKEN to the minimal scopes needed. For an issue/comment notification workflow that only reads event payloads and sends a Slack message via a secret, no write permissions are needed; read-only access is sufficient, and often only contents: read (and optionally issues: read) is required.

The best fix here without changing functionality is to add a top-level permissions: block (applies to all jobs) near the top of .github/workflows/issue-notification.yml, underneath name: (or on:). Since the jobs simply consume github.event.issue and github.event.comment fields and delegate to a reusable Slack notification workflow, they do not perform any write operations on the repository. A safe and minimal configuration is:

permissions:
  contents: read
  issues: read

If the reusable workflow needs no GitHub API access, even issues: read may be unnecessary, but including it is harmless and explicit. No imports, methods, or additional definitions are needed; this is purely a YAML configuration change inside .github/workflows/issue-notification.yml.

Suggested changeset 1
.github/workflows/issue-notification.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/issue-notification.yml b/.github/workflows/issue-notification.yml
--- a/.github/workflows/issue-notification.yml
+++ b/.github/workflows/issue-notification.yml
@@ -1,4 +1,7 @@
 name: Issue Created Notification
+permissions:
+  contents: read
+  issues: read
 on:
   issues:
     types: [opened, reopened]
EOF
@@ -1,4 +1,7 @@
name: Issue Created Notification
permissions:
contents: read
issues: read
on:
issues:
types: [opened, reopened]
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant