Skip to content

Potential fix for code scanning alert no. 901: Workflow does not contain permissions#584

Open
aurelianware wants to merge 2 commits intomainfrom
alert-autofix-901
Open

Potential fix for code scanning alert no. 901: Workflow does not contain permissions#584
aurelianware wants to merge 2 commits intomainfrom
alert-autofix-901

Conversation

@aurelianware
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/aurelianware/cloudhealthoffice/security/code-scanning/901

In general, the fix is to explicitly set a permissions: block to restrict the default GITHUB_TOKEN scope to the least privileges required. This block can be set at the top level of the workflow (applies to all jobs) or per-job. Since both jobs in this workflow are simple deploy/close actions and there is no evidence of needing broad write access, the safest change is to add a top-level permissions: block with read-only repository contents (and no other scopes) unless the action explicitly requires additional scopes.

The single best change here, without altering existing functionality, is to add a workflow-level permissions: section just below the on: block. As a minimal, conservative configuration, we can set contents: read, which matches the CodeQL suggestion and is typically sufficient for actions that only need to read repo content and post PR comments via repo_token. The rest of the workflow remains unchanged. No extra imports or methods are needed because this is purely configuration in the YAML workflow file.

Concretely:

  • Edit .github/workflows/azure-static-web-apps-agreeable-meadow-0da15b31e.yml.
  • After the on: section (after line 10/11), insert:
permissions:
  contents: read

This ensures both build_and_deploy_job and close_pull_request_job inherit the restricted permissions unless they later define their own permissions block.

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

…ain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Aurelianware <markus@aurelianware.com>
@aurelianware
Copy link
Copy Markdown
Owner Author

@copilot can you fix the lint check that’s failing

@aurelianware aurelianware marked this pull request as ready for review March 27, 2026 18:41
Copilot AI review requested due to automatic review settings March 27, 2026 18:41
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

@copilot can you fix the lint check that’s failing

Fixed in commit 6b0fc8f. The yamllint failure was caused by Windows-style CRLF line endings in the workflow file — converted them to LF, which resolves the [error] wrong new line character: expected \n error.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an explicit permissions block to the Azure Static Web Apps CI/CD workflow to address code scanning alert #901 by restricting default GITHUB_TOKEN privileges.

Changes:

  • Add workflow-level permissions with contents: read to limit GITHUB_TOKEN scope.

Comment on lines +12 to +13
permissions:
contents: read
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The new workflow-level permissions restricts GITHUB_TOKEN to contents: read, but this workflow passes secrets.GITHUB_TOKEN as repo_token to Azure/static-web-apps-deploy@v1 (notably for PR integrations/PR comments). With only contents: read, the action will no longer be able to create/update PR comments or other PR metadata, changing existing behavior. Consider adding the minimal additional scopes required (typically pull-requests: write, and scope it per-job if you want close_pull_request_job to remain read-only).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants