feat: guard M365 pilot scopes#38
Conversation
|
Warning Review limit reached
More reviews will be available in 53 minutes and 30 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds three planning documents describing Workit as a KHAW canonical plugin with Hermes approval for M365 writes, and implements a Go pilot scope guard (internal/msauth) enforcing an ordered read-only allowlist with normalization and fail-closed rejection. ChangesM365 Write Approval & Pilot Scope Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces integration plans, write approval contracts, and implementation plans for the Workit M365 integration, alongside a new msauth package that restricts Microsoft Graph scopes to a read-only baseline for the pilot. The review feedback suggests enhancing the scope guard's robustness and maintainability by dynamically initializing the allowed scope set to avoid duplication, supporting case-insensitive scope validation, and updating the unit tests to verify this behavior.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/msauth/scopes.go`:
- Around line 49-50: There is a linter spacing issue: after calling
canonicalPilotScope and assigning canonical, allowed, add a single blank line
before the subsequent conditional `if !allowed` to satisfy golangci-lint; update
the block around the `canonical, allowed := canonicalPilotScope(trimmed)`
statement (in scopes.go) so there is an empty line separating that assignment
from the `if !allowed` check, preserving existing logic and variable names.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 14014bf9-ac63-4c34-9b71-05210010c6a7
📒 Files selected for processing (3)
.deadcode-baseline.txtinternal/msauth/scopes.gointernal/msauth/scopes_test.go
✅ Files skipped from review due to trivial changes (1)
- .deadcode-baseline.txt
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/msauth/scopes_test.go
Summary\n- add Workit M365 pilot scope guard with explicit read-only allowlist\n- document and link the M365 write-gate implementation/approval contract\n- reject write/unknown Microsoft Graph scopes fail-closed\n\n## Tests\n- /tmp/go1.25.10/bin/go test ./...
Summary by CodeRabbit