Skip to content
Closed
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
9 changes: 9 additions & 0 deletions .github/workflows/secrets-scan-on-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Secrets Scan

on:
pull_request:

jobs:
scan:
uses: AirHelp/gh-actions/.github/workflows/secrets-scan-on-pr.yaml@master
secrets: inherit
Comment on lines +8 to +9

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 4 months ago

In general, the problem is fixed by explicitly adding a permissions block to the workflow or to the specific job so that the GITHUB_TOKEN has only the minimum required access. Since this workflow only defines a single job that calls a reusable workflow, and we don’t know any need for write access from this file, we can safely restrict permissions to read-only for repository contents.

The best minimal change is to add a permissions block at the workflow (top) level, just under name: Secrets Scan. This will apply to all jobs in this workflow (including scan) unless they override permissions themselves. A conservative least-privilege choice is contents: read, which allows the reusable workflow to read repository contents while preventing write operations with the GITHUB_TOKEN from this workflow’s context.

Concretely, in .github/workflows/secrets-scan-on-pr.yaml, insert:

permissions:
  contents: read

between line 1 (name: Secrets Scan) and line 3 (on:). No additional imports, methods, or definitions are needed because this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/secrets-scan-on-pr.yaml

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/secrets-scan-on-pr.yaml b/.github/workflows/secrets-scan-on-pr.yaml
--- a/.github/workflows/secrets-scan-on-pr.yaml
+++ b/.github/workflows/secrets-scan-on-pr.yaml
@@ -1,4 +1,6 @@
 name: Secrets Scan
+permissions:
+  contents: read
 
 on:
   pull_request:
EOF
@@ -1,4 +1,6 @@
name: Secrets Scan
permissions:
contents: read

on:
pull_request:
Copilot is powered by AI and may make mistakes. Always verify output.
Loading