Skip to content

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

Merged
remdui merged 2 commits intomainfrom
alert-autofix-2
Mar 24, 2026
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#4
remdui merged 2 commits intomainfrom
alert-autofix-2

Conversation

@remdui
Copy link
Copy Markdown
Member

@remdui remdui commented Mar 24, 2026

Potential fix for https://github.com/HauntedMC/DataProvider/security/code-scanning/2

In general, fix this by explicitly defining a permissions block to restrict the GITHUB_TOKEN to the minimal scope needed. This can be placed at the workflow root (applies to all jobs without their own permissions) or on individual jobs.

For this workflow, the single best fix without changing functionality is to add a root-level permissions block after the on: section (or before jobs:). The job only checks out code, sets up Java, runs Maven tests, and uploads artifacts; these require only read access to repository contents. Therefore we can safely set:

permissions:
  contents: read

Edit .github/workflows/ci-tests-and-coverage.yml between the on: block and the jobs: block, inserting the permissions mapping. No imports, methods, or other definitions are needed, as this is declarative YAML configuration only.

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

remdui and others added 2 commits March 24, 2026 22:14
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Remy Duijsens <remyduijsens@gmail.com>
@remdui remdui marked this pull request as ready for review March 24, 2026 21:15
@remdui remdui merged commit 65fd438 into main Mar 24, 2026
6 checks passed
@remdui remdui deleted the alert-autofix-2 branch March 24, 2026 21:17
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