Repository navigation
chore(tests): Restrict repository permissions for the test workflow - #48
jonaseberle wants to merge 1 commit into
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2913048 to
a20e749
Compare
There was a problem hiding this comment.
praise: Thanks, Jonas. This repo's default workflow token can write, so this is worth merging. It closes code scanning alert 3, the same rule as alert 2, which GitHub marked fixed when the file changed.
question: #65 passes the workflow token to ddev utility download-ddev --head, which downloads the build from ddev/ddev's artifacts. Does that still work with only contents: read, or does the job need actions: read? Once #65 merges, we'll update this branch, and the head jobs' logs should show whether it fell back to nightly.link.
Drafted with Claude Code using project-triage. I had the change checked with zizmor and against the repo's token settings and code scanning alerts, chose which points to raise, and reviewed the final text.
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
suggestion (non-blocking): I'd prefer permissions: {} here, with the test job's permissions on the job and a comment saying why, e.g. contents: read # actions/checkout. Then any job added later starts with no permissions.
Potential fix for https://github.com/ddev/github-action-setup-ddev/security/code-scanning/2
To fix the problem, explicitly set the minimal required
permissionsfor the workflow. Since the workflow does not perform any actions that require write permissions (e.g., it does not comment on PRs, update statuses, or push commits), settingpermissions: contents: readat the workflow level (the root) is the preferred solution. This restricts theGITHUB_TOKENto read-only access to repository contents, greatly reducing the attack surface.Specifically, add the following at the top level of
.github/workflows/main.yml, after thename:and before theon:block:No changes are required to the existing jobs or steps, as none are observed to require greater permissions.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.