-
Notifications
You must be signed in to change notification settings - Fork 3
fix: --scan-root argument macos postinstall script, auto-updated #125
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
Conversation
WalkthroughUpdate service enhancements across macOS, Windows, and Linux with platform-specific workflows. macOS now handles DMG mounting and app bundle installation, Linux introduces staged binary updates with verification, Windows uses the go-update library, and the macOS wrapper script now invokes the CLI binary directly instead of the GUI. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Main as main.go
participant UpdateSvc as UpdateService
participant FileSystem as File System
App->>Main: Start Application
Main->>UpdateSvc: CheckPendingUpdate()
alt Pending Update Exists
UpdateSvc->>FileSystem: Read .next binary
UpdateSvc->>FileSystem: Verify binary (ELF magic, size)
UpdateSvc->>FileSystem: Atomic swap .next → current binary
UpdateSvc->>UpdateSvc: Restart into new binary
UpdateSvc-->>Main: Success (or Rollback on failure)
else No Pending Update
UpdateSvc-->>Main: Return nil
end
Main->>Main: cmd.Execute()
sequenceDiagram
participant Update as Update Process
participant Asset as Asset Source
participant Binary as Binary Staging
participant Verify as Verification
participant Restart as Restart Handler
rect rgb(200, 230, 255)
Note over Update,Restart: macOS Update Flow
Update->>Asset: Download DMG
Update->>Binary: Mount DMG, locate .app
Update->>Binary: Copy app to /Applications (rsync/cp)
Update->>Verify: Clear quarantine attributes
Update->>Restart: Restart updated app
end
rect rgb(230, 200, 255)
Note over Update,Restart: Linux Update Flow
Update->>Asset: Download ZIP, detect binary (webkit version)
Update->>Binary: Identify executable (prefer "scanoss" in name)
Update->>Verify: Verify binary (ELF magic, size)
Update->>Binary: Stage to .next path
Update->>Restart: Trigger restart (finalize on next run via CheckPendingUpdate)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions 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 |
SCANOSS SCAN Completed 🚀
View more details on SCANOSS Action Summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
backend/service/update_service_impl.go (1)
303-315: Consider letting hdiutil create the mount point.The code creates the
mountPointdirectory before callinghdiutil attach. Whilehdiutilcan use an existing directory, it's more idiomatic to let it create the mount point automatically by omitting the-mountpointflag and parsing the output to determine where it was mounted.However, the current approach works correctly and provides explicit control over the mount location for cleanup purposes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
CHANGELOG.md(2 hunks)backend/service/update_service_impl.go(7 hunks)go.mod(1 hunks)main.go(1 hunks)scripts/install-macos.sh(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
main.go (1)
backend/service/update_service_impl.go (1)
CheckPendingUpdate(637-690)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (7)
main.go (1)
66-68: LGTM! Intentional error handling for startup update check.The error from
CheckPendingUpdate()is intentionally ignored, which is appropriate given the function's design:
- It returns
nilfor non-Linux platforms- It silently handles errors during startup to avoid blocking application launch
- On successful update, it re-execs into the new binary, so this code path doesn't return
The implementation in
CheckPendingUpdate()also correctly handles the restart scenario by cleaning up the.oldbackup file when no pending update exists.backend/service/update_service_impl.go (5)
337-375: LGTM! Robust macOS update implementation with fallback.The implementation properly handles:
- Atomic installation using
rsyncwith--deleteflag- Fallback to
cpifrsyncis unavailable- Quarantine attribute clearing to avoid security warnings
- Proper application restart using the
opencommand- Clean shutdown of the current instance
395-470: LGTM! Windows update correctly uses go-update library.The implementation properly addresses Windows-specific challenges:
- Uses PowerShell's
Expand-Archivefor ZIP extraction (available on all modern Windows)- Leverages the
go-updatelibrary to handle Windows file locking issues when replacing running executables- Preserves command-line arguments when restarting
- Properly shuts down the current instance
507-579: LGTM! Linux update uses robust staging approach.The implementation correctly handles Linux-specific constraints:
- Intelligent binary detection that prefers files with "scanoss" in the name, with fallback to first executable
- Verifies the binary before staging (ELF magic check, size check)
- Uses a staging approach (
.nextfile) to avoid issues with replacing running executables- Atomic swap is deferred to application startup via
CheckPendingUpdate()- Proper error handling with cleanup on failure
581-633: LGTM! Good basic verification and file copy utilities.
verifyLinuxBinary()provides essential checks:
- Minimum size validation (1MB threshold)
- ELF magic number verification to ensure it's a valid Linux binary
copyFile()implements a reliable file copy withSync()to ensure data is persisted to disk.
635-695: LGTM! Well-designed startup update mechanism.
CheckPendingUpdate()is correctly implemented:
- Platform-specific (Linux only)
- Silently handles errors to avoid blocking startup
- Performs atomic binary swap with rollback on failure
- Cleans up old backups automatically
- Re-execs into the new binary on successful update
restartApplication()provides a clean abstraction for the restart operation.go.mod (1)
34-34: Consider migrating to a maintained alternative forgo-update.The version
v0.0.0-20160112193335-8152e7eb6ccfis confirmed to be the latest available from the repository, last updated on 2016-01-12, and no known security vulnerabilities are registered. However, the original repository is low-activity with no strong active maintenance guarantees. Actively maintained alternatives includeminio/selfupdate(a drop-in replacement),rhysd/go-github-selfupdate(for GitHub-release-driven workflows), andcreativeprojects/go-selfupdate(with broader provider support). Evaluate whether migrating to one of these maintained forks is feasible for your use case.
Summary by CodeRabbit
New Features
Bug Fixes
Changed