-
-
Notifications
You must be signed in to change notification settings - Fork 947
[client] auto-update #4732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/auto-upgrade
Are you sure you want to change the base?
[client] auto-update #4732
Conversation
- Copy dll file
Change priority of updates
a93f3b7 to
d3fd3f0
Compare
60598f8 to
6a52694
Compare
e332550 to
f15c80c
Compare
|
@coderabbitai review this PR |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 264151 @pappz I'll review this PR for you. This is a substantial feature addition implementing client auto-update functionality. Let me analyze the key aspects: Architecture OverviewThe PR implements a two-process architecture for self-updates:
This separation is well-designed to handle the limitation that a service cannot update itself while running. Key Strengths✅ Strong Cryptographic Foundation: The ✅ Security Features:
✅ Good Documentation: Comprehensive package documentation in ✅ Result Communication: Clean IPC mechanism via JSON files between updater and service Concerns & Recommendations1. Security: Missing Signature Verification Before ExecutionThe Recommendation: Move artifact verification to happen in the service process before copying the updater binary. 2. Error Handling: Silent FailuresIn func Execute() error {
if isUpdateBinary() {
return updateCmd.Execute()
}
return rootCmd.Execute()
}If Recommendation: Add logging before returning errors from update execution. 3. Resource Leak: Missing CleanupIn launchCmd := exec.Command("launchctl", "asuser", userInfo.Uid, "open", "-a", uiBinary)
if err := launchCmd.Start(); err != nil {
return fmt.Errorf("failed to start UI process: %w", err)
}
if err := launchCmd.Process.Release(); err != nil {
log.Warnf("failed to release UI process: %v", err)
}The command could fail after Recommendation: Use defer for cleanup: if err := launchCmd.Start(); err != nil {
return fmt.Errorf("failed to start UI process: %w", err)
}
defer func() {
if err := launchCmd.Process.Release(); err != nil {
log.Warnf("failed to release UI process: %v", err)
}
}()4. Race Condition: Update State ManagementIn func (m *Manager) CheckUpdateSuccess(ctx context.Context) {
reason := m.lastResultErrReason()
if reason != "" {
// Publish error event
}
updateState, err := m.loadAndDeleteUpdateState(ctx)
// If process crashes here, state is deleted but success event not publishedRecommendation: Delete state only after successfully publishing events. 5. Platform-Specific: macOS Homebrew HandlingThe Homebrew update path sends SIGTERM to the current process which may not guarantee a clean shutdown if there are active connections: err = process.Signal(syscall.SIGTERM)Recommendation: Consider implementing graceful shutdown with a timeout, similar to how Docker handles SIGTERM + SIGKILL. 6. Testing: Limited Integration TestsI see unit tests for the signing system but no integration tests for the full update flow. The update process involves multiple steps across processes. Recommendation: Add integration tests that verify:
7. Observability: Missing MetricsThere's no telemetry for update operations. Consider tracking:
8. Documentation: Installation Flow UnclearThe // updateCmd.SysProcAttr = &syscall.SysProcAttr{
// CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP | 0x00000008,
// }This commented code suggests incomplete Windows process detachment. Is this intentional? Recommendation: Either implement properly or document why it's not needed. Minor Issues
VerdictThis is well-architected code with strong security foundations, but it needs refinement in error handling, resource management, and testing before merging. The cryptographic implementation is solid, but the update orchestration layer needs hardening. Suggested Priority:
Would you like me to focus on any specific area in more detail? |
Make auto-update behavior configurable by adding a parameter to menuUpClick. When connecting normally, auto-update is enabled (true). When switching profiles, auto-update is disabled (false) to prevent automatic updates during profile changes.
|



Describe your changes
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__