Conversation
- Add secrets-scan-on-pr.yaml workflow that runs on pull requests - Uses detect-secrets-action to scan for accidentally committed secrets - Required for all PRs as per repository requirements
cc92838 to
9c469e4
Compare
| uses: AirHelp/gh-actions/.github/workflows/secrets-scan-on-pr.yaml@master | ||
| secrets: inherit |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 29 days 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: readbetween 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.
| @@ -1,4 +1,6 @@ | ||
| name: Secrets Scan | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: |
Add required secrets scanning workflow that runs on pull requests to detect accidentally committed secrets.
Changes
.github/workflows/secrets-scan-on-pr.yamlTesting
The workflow will automatically run on this PR to verify it works correctly.