Potential fix for code scanning alerts: Workflow does not contain permissions#1164
Potential fix for code scanning alerts: Workflow does not contain permissions#1164
Conversation
…ain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
599be49 to
2ee4488
Compare
…ain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ewer into alert-autofix-450
There was a problem hiding this comment.
Pull request overview
This PR aims to address GitHub code scanning alerts about missing/overly broad GITHUB_TOKEN permissions by adding explicit permissions blocks to workflows/jobs.
Changes:
- Add workflow-level
permissions: contents: readtotest-and-deploy.yml. - Add job-level
permissions: contents: readto theevent_filejob intest-and-deploy.yml. - Add workflow-level
permissions: contents: readtodeploy-embed-test.yml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/test-and-deploy.yml | Adds explicit permissions at workflow and event_file job level to satisfy code scanning. |
| .github/workflows/deploy-embed-test.yml | Adds explicit workflow-level permissions (contents: read). |
Comments suppressed due to low confidence (1)
.github/workflows/test-and-deploy.yml:5
- PR description says the change is limited to adding a job-level permissions block to
event_fileintest-and-deploy.yml, but this also adds workflow-level permissions and updates an additional workflow (deploy-embed-test.yml). Either update the PR description to match the actual changes or narrow the changes to what’s described.
permissions:
contents: read
| name: 'Test and deploy' | ||
|
|
||
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
The new workflow-level permissions: contents: read applies to all jobs that don’t define their own permissions. This workflow uses actions/upload-artifact in the test and event_file jobs, which requires actions access; with only contents: read those uploads are likely to fail. Consider either (a) adding actions: write to the jobs that upload artifacts (and keep workflow-level permissions empty or minimal), or (b) broadening the workflow-level permissions to include what those jobs need.
| contents: read | |
| contents: read | |
| actions: write |
Potentialfixforhttps://github.com/Tailormap/tailormap-viewer/security/code-scanning/450
Tofix the problem, give the
event_filejob its own explicit, least-privilegepermissionsblock so it does not inherit broad defaults. Because this job only needs to read the workflow event JSON from the checkout/context and upload it as an artifact, it only requirescontents: read. It does not modify code, issues, or PRs.Concretely, in
.github/workflows/test-and-deploy.yml, inside theevent_filejob (around lines 100–108), add apermissions:section withcontents: read. Place it at the same indentation level asruns-on:andsteps:. No imports or other files are needed, and no behavior of the job changes; it simply restricts the GITHUB_TOKEN for this job.resolve:
Suggested fixes powered by Copilot Autofix. Review carefully before merging.