Skip to content

Potential fix for code scanning alert no. 6: Workflow does not contain permissions#40

Merged
ss-o merged 1 commit into
mainfrom
alert-autofix-6
Mar 30, 2026
Merged

Potential fix for code scanning alert no. 6: Workflow does not contain permissions#40
ss-o merged 1 commit into
mainfrom
alert-autofix-6

Conversation

@ss-o

@ss-o ss-o commented Mar 30, 2026

Copy link
Copy Markdown
Member

Potential fix for https://github.com/z-shell/zbrowse/security/code-scanning/6

In general, the fix is to explicitly declare the minimal GITHUB_TOKEN permissions required by this workflow, instead of relying on repository/organization defaults. Because both jobs only need to read repository contents (for actions/checkout) and do not perform any write operations via the GitHub API, we can safely set contents: read at the workflow level. This will apply to both jobs and documents that the workflow requires only read access.

The best fix with no functional change is to add a root-level permissions: block just after the name: (or after the on: section, but root-level) in .github/workflows/zsh-n.yml. For this workflow, a minimal and sufficient block is:

permissions:
  contents: read

This restricts the GITHUB_TOKEN to read-only for repository contents, which still allows actions/checkout to function. No other permissions (such as pull-requests or issues) are needed because the workflow does not interact with those resources. No additional imports or methods are required; it is a pure YAML configuration change.

Concretely, in .github/workflows/zsh-n.yml, insert the permissions block near the top of the file, without modifying any of the existing jobs or steps. All existing behavior (checking out code, finding .zsh files, running zsh -n and zcompile) will continue to work unchanged.

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>
Signed-off-by: Sall <59910950+ss-o@users.noreply.github.com>
@ss-o ss-o marked this pull request as ready for review March 30, 2026 04:44
Copilot AI review requested due to automatic review settings March 30, 2026 04:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the zsh-n GitHub Actions workflow to address code scanning alert #6 by explicitly setting minimal GITHUB_TOKEN permissions at the workflow level.

Changes:

  • Add a root-level permissions: block to restrict GITHUB_TOKEN to contents: read for this workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ss-o ss-o merged commit ceebeb7 into main Mar 30, 2026
6 checks passed
@ss-o ss-o deleted the alert-autofix-6 branch March 30, 2026 04:47
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Pull Request closed and locked due to lack of activity. If you'd like to build on this closed PR, you can clone it using this method: https://stackoverflow.com/a/14969986 Then open a new PR, referencing this closed PR in your message.

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants