Recovery password: GET API - #41436
Conversation
For the following quick win: - #40354
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #41436 +/- ##
==========================================
+ Coverage 66.36% 66.39% +0.03%
==========================================
Files 2491 2480 -11
Lines 199288 199003 -285
Branches 8942 8611 -331
==========================================
- Hits 132256 132135 -121
+ Misses 55076 54911 -165
- Partials 11956 11957 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughThis pull request adds a new API endpoint to retrieve the recovery lock password for a host. The changes include introducing a new activity type for tracking password access, registering a new service method in the Service interface, implementing the endpoint with authorization validation and MDM configuration checks, and updating mock implementations. The implementation logs an activity entry when the password is accessed and includes proper error handling. Possibly related PRs
🚥 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)
📝 Coding Plan for PR comments
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.
🧹 Nitpick comments (1)
server/service/hosts.go (1)
3725-3737: Consider adding platform validation.Recovery lock password is an Apple-specific feature (macOS Apple Silicon). While the database query will return "not found" for non-macOS hosts, adding a platform check would provide a clearer error message and avoid unnecessary database calls.
💡 Optional: Add platform check
// Check that MDM is enabled appConfig, err := svc.ds.AppConfig(ctx) if err != nil { return nil, ctxerr.Wrap(ctx, err, "get app config") } if !appConfig.MDM.EnabledAndConfigured { return nil, fleet.ErrMDMNotConfigured } + // Recovery lock password is only available for macOS hosts + if host.Platform != "darwin" { + return nil, ctxerr.Wrap(ctx, newNotFoundError(), "recovery lock password is only available for macOS hosts") + } + password, err := svc.ds.GetHostRecoveryLockPassword(ctx, host.UUID)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/service/hosts.go` around lines 3725 - 3737, Before calling svc.ds.GetHostRecoveryLockPassword, check the host platform (e.g., host.Platform or host.OS) and only proceed for macOS/Apple Silicon hosts (e.g., "darwin"/"macos"); if the host is not macOS, return a clear platform-specific error (e.g., a wrapped error like fmt.Errorf("recovery lock not supported on platform %s", host.Platform)) to avoid the unnecessary DB query and provide a clearer message—make this change around the existing appConfig.MDM.EnabledAndConfigured check and the svc.ds.GetHostRecoveryLockPassword call, referencing host.UUID and svc.ds.GetHostRecoveryLockPassword.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/service/hosts.go`:
- Around line 3725-3737: Before calling svc.ds.GetHostRecoveryLockPassword,
check the host platform (e.g., host.Platform or host.OS) and only proceed for
macOS/Apple Silicon hosts (e.g., "darwin"/"macos"); if the host is not macOS,
return a clear platform-specific error (e.g., a wrapped error like
fmt.Errorf("recovery lock not supported on platform %s", host.Platform)) to
avoid the unnecessary DB query and provide a clearer message—make this change
around the existing appConfig.MDM.EnabledAndConfigured check and the
svc.ds.GetHostRecoveryLockPassword call, referencing host.UUID and
svc.ds.GetHostRecoveryLockPassword.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c78051e8-aa9e-44c5-b4b9-2e649340fce1
📒 Files selected for processing (5)
server/fleet/activities.goserver/fleet/service.goserver/mock/service/service_mock.goserver/service/handler.goserver/service/hosts.go
Related issue: Resolves #40658
Summary by CodeRabbit
New Features
Chores