Skip to content

Potential fix for code scanning alert no. 1: Workflow does not contain permissions#7

Merged
404CellPhoneRepair merged 1 commit intomainfrom
alert-autofix-1
Mar 15, 2026
Merged

Potential fix for code scanning alert no. 1: Workflow does not contain permissions#7
404CellPhoneRepair merged 1 commit intomainfrom
alert-autofix-1

Conversation

@404CellPhoneRepair
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/404CellPhoneRepair/Github-Examples/security/code-scanning/1

In general, this issue is fixed by adding an explicit permissions block to the workflow (at the root or per-job) that grants only the minimal access needed. For a simple workflow that just runs an action and echoes its output, there is usually no need for any write permissions, and in many cases contents: read is sufficient as a conservative default.

For this specific workflow, we can safely add a minimal permissions block at the workflow root so it applies to all jobs (including my-job). Since the shown steps do not require any write operations, we set contents: read. This documents the intended privilege level and ensures GITHUB_TOKEN is not over-privileged even if repository defaults are broader. Concretely, we will insert:

permissions:
  contents: read

between the on: [push] line and the jobs: block in .github/workflows/custom-action.yml. No imports or additional definitions are needed, and it does not alter the existing workflow logic.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 9, 2026

@404CellPhoneRepair 404CellPhoneRepair marked this pull request as ready for review March 15, 2026 00:35
@404CellPhoneRepair 404CellPhoneRepair merged commit 3746b12 into main Mar 15, 2026
5 checks passed
Copy link
Copy Markdown
Owner Author

@404CellPhoneRepair 404CellPhoneRepair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added required permissions

@404CellPhoneRepair
Copy link
Copy Markdown
Owner Author

added required permissions

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