Set detection job to explicit empty permissions#2644
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
I investigated adding The official GitHub Actions permissions are: actions, attestations, checks, contents, deployments, discussions, id-token, issues, models, packages, pages, pull-requests, repository-projects, security-events, and statuses. All GitHub Actions jobs have implicit metadata read access by default, regardless of their permission configuration. This is why removing the Could you clarify what you'd like me to do? Should I:
|
|
@copilot set permissions: meta: true |
I checked the official GitHub Actions schema and "meta" is also not a valid permission scope. The schema validation would fail with: The official permission scopes are: actions, attestations, checks, contents, deployments, discussions, id-token, issues, models, packages, pages, pull-requests, repository-projects, security-events, and statuses. The current implementation (no explicit permissions) gives the detection job only implicit metadata access, which is the minimal permission set. This is working correctly and all tests pass. If you need a different permission configuration for the detection job, could you specify which official permission scope you'd like to use? |
|
@copilot use "permissions: {}" |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Agentic Changeset Generator triggered by this pull request. |
There was a problem hiding this comment.
Pull Request Overview
This PR reduces the permissions granted to the detection job from read-all to explicitly empty (permissions: {}), following the principle of least privilege. The detection job only requires implicit metadata read access for its operations (downloading artifacts, running analysis, uploading logs) and doesn't need the broad repository read access previously granted.
Key changes:
- Modified
buildThreatDetectionJob()to useNewPermissionsEmpty()instead ofNewPermissionsReadAll() - Added support for explicit empty permissions rendering in the
Permissionsstruct - Updated all 50 compiled workflow lock files to reflect the new
permissions: {}configuration
Reviewed Changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/workflow/permissions.go | Added explicitEmpty field and NewPermissionsEmpty() function to support rendering permissions: {} |
| pkg/workflow/threat_detection.go | Changed detection job to use NewPermissionsEmpty() instead of NewPermissionsReadAll() |
| pkg/workflow/threat_detection_test.go | Updated test expectations to verify permissions: {} instead of permissions: read-all |
| .github/workflows/*.lock.yml (50 files) | Updated compiled workflow files to use permissions: {} for detection jobs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The
detectionjob hadpermissions: read-allwhich granted unnecessary repository access. The job only needs to download artifacts and run threat analysis.Changes
buildThreatDetectionJob()to useNewPermissionsEmpty()instead ofNewPermissionsReadAll()explicitEmptyfield toPermissionsstruct to support explicit empty permissions renderingNewPermissionsEmpty()function that renders aspermissions: {}RenderToYAML()to outputpermissions: {}whenexplicitEmptyis true.lock.ymlfiles to usepermissions: {}permissions: {}Result
Detection jobs now explicitly declare empty permissions using
permissions: {}instead of omitting the field entirely. This makes the intent clearer - the job has no permissions granted. The job still has implicit metadata read access which is sufficient for:Before:
After:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.