Skip to content

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#253

Closed
DCSBL wants to merge 4 commits intomainfrom
alert-autofix-2
Closed

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#253
DCSBL wants to merge 4 commits intomainfrom
alert-autofix-2

Conversation

@DCSBL
Copy link
Collaborator

@DCSBL DCSBL commented Mar 24, 2026

Potential fix for https://github.com/homewizard/api-documentation/security/code-scanning/2

In general, this should be fixed by explicitly declaring a permissions block in the workflow (at the root or per job) so that the GITHUB_TOKEN is restricted to the least privileges required. For most build/test/deploy preview jobs, a safe baseline is contents: read. If the workflow or any actions it uses require additional scopes (e.g., to comment on PRs or update deployment statuses), those specific permissions (like pull-requests: write) should be added explicitly instead of relying on broad defaults.

For this specific workflow in .github/workflows/firebase-hosting-pull-request.yml, the simplest and least intrusive fix is to add a root‑level permissions block directly under the name: (or under on:) so it applies to all jobs. Starting with contents: read documents that this workflow expects only read access to repository contents. If later it’s discovered that FirebaseExtended/action-hosting-deploy@v0 needs additional scopes, those can be explicitly added, but that’s outside the static analysis finding. No imports or other files need to be changed; the change is a small YAML addition near the top of this file.

Concretely:

  • Edit .github/workflows/firebase-hosting-pull-request.yml.

  • Insert:

    permissions:
      contents: read

    after line 1 (the name: line), keeping indentation consistent.

  • Leave the rest of the workflow untouched so all existing behavior remains the same, except for the tightened token permissions.


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

DCSBL and others added 4 commits March 24, 2026 16:41
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Duco Sebel <74970928+DCSBL@users.noreply.github.com>
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Duco Sebel <74970928+DCSBL@users.noreply.github.com>
Signed-off-by: Duco Sebel <74970928+DCSBL@users.noreply.github.com>
Signed-off-by: Duco Sebel <74970928+DCSBL@users.noreply.github.com>
@DCSBL DCSBL marked this pull request as ready for review March 24, 2026 15:45
@DCSBL DCSBL closed this Mar 24, 2026
@DCSBL DCSBL deleted the alert-autofix-2 branch March 24, 2026 15:47
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