[BRE-1333] [key-connector] Update workflow permissions#243
[BRE-1333] [key-connector] Update workflow permissions#243gitclonebrian merged 3 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #243 +/- ##
=====================================
Coverage 7.04% 7.04%
=====================================
Files 49 49
Lines 1818 1818
Branches 99 99
=====================================
Hits 128 128
Misses 1685 1685
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Fixed Issues (1)Great job! The following issues were fixed in this Pull Request
|
|
Claude finished @gitclonebrian's task —— View job Code Review CompleteSummaryThis PR implements principle of least privilege by restricting workflow-level permissions and moving content write access to the GitHub App token scope. The changes are well-executed and align with security best practices for GitHub Actions. FindingsFinding 1: PR description could be more specific about the security improvement achieved 💭 The objective states "Limit scope of generated app token" but doesn't explain why this improves security or what the previous state was. Consider adding context about the principle of least privilege and explaining that this ensures the workflow token (GITHUB_TOKEN) has minimal permissions while the app token gets only the specific permissions needed. Suggested improvement## 📔 Objective
Apply principle of least privilege to workflow permissions per [BRE-1333](https://bitwarden.atlassian.net/browse/BRE-1333).
**Changes:**
- Set workflow-level permissions to empty (`{}`) to ensure GITHUB_TOKEN has no default permissions
- Removed `contents: write` and `pull-requests: write` from job-level permissions (no longer needed)
- Added `permissions-contents: write` to GitHub App token generation step (only component needing write access)
- Retained `id-token: write` at job level for Azure OIDC authentication
**Security benefit:** Limits exposure by ensuring only the generated app token (used for git operations) has repository write access, while the workflow's GITHUB_TOKEN operates with minimal permissions.Finding 2: Missing
ContextPrevious permissions at job level: permissions:
contents: write
pull-requests: write
id-token: writeCurrent permissions at job level: permissions:
id-token: writeCurrent app token permissions: permission-contents: writeIf this workflow needs to create/update PRs, you may need to add Good Practices Observed
Action Items
|


🎟️ Tracking
BRE-1333
📔 Objective
Limit scope of generated app token and ensure appropriate permissions are set at the workflow and job levels.
Test run was successful.
📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes