Skip to content

Share the updater's verified stream loop and split run() - #32

Merged
sudo-py-dev merged 1 commit into
mainfrom
refactor/updater-stream-and-run
Nov 25, 2026
Merged

sudo-py-dev merged 1 commit into
mainfrom
refactor/updater-stream-and-run

Conversation

@sudo-py-dev

Copy link
Copy Markdown
Owner

Summary

Two behaviour-preserving refactors from a CodeHawk audit (findings CQ-001 and CQ-002).

src/updater.rs: one verified stream loop (CQ-002)
The download path (verify_download_progress) and the privileged .deb copy (copy_verified_package) each had their own bounded read → signature-verify → write loop. Both now call a single stream_verified(reader, writer, limit, verifier, on_chunk):

  • the same 64 KiB chunks, take(limit + 1) bound, checked slicing and "exceeds expected size" error;
  • downloads track SHA-256 and progress via on_chunk, then keep their exact-size and digest checks;
  • both callers still call verifier.finalize() themselves, in the same order as before.

This is the code that decides whether an update is trusted, so a future hardening change now reaches both paths at once.

src/main.rs: split run() (CQ-001)
run() was 370 lines with about 62 branches. It's now 34 lines, and its callbacks move unchanged into:

  • register_settings: language, links, debug log, folder shortcuts, reduce motion, Windows restart-as-administrator
  • register_source_actions: the action!/action_with! buttons
  • register_preview, plus a flat show_preview() that replaces the 6-level nested preview handler
  • register_updates, which returns the shared Updates
  • start_polling, which returns the 100 ms timer; run() holds it as _timer

This follows the existing register_drive_checks pattern. Drive monitoring still starts before the source callbacks are registered.

Notes for reviewers

  • No behaviour change is intended. The moved code is byte-for-byte the same, except Rc::clone(&state) becomes Rc::clone(state) now that state is a reference.
  • The audit's third finding (SEC-001, unmaintained RustSec crates) needs no change. deny.toml already ignores them with reasons and a 2026-12-15 expiry, and bincode isn't in the resolved graph.

Testing

  • cargo fmt --check and cargo clippy --locked --all-targets -- -D warnings are clean on Linux.
  • cargo test --locked --no-fail-fast passes, including the updater's corruption, truncation and oversize tests and the audit suite.
  • The Windows and macOS builds weren't compiled locally. CI covers them; note the #[cfg(windows)] restart-as-administrator block now lives in register_settings.

🤖 Generated with Claude Code

The download path and the privileged .deb copy each carried their own
bounded read/verify/write loop. Both now use stream_verified(), so a
future hardening change to how update bytes are streamed and checked
reaches both paths. Callers keep their own final checks (exact size and
SHA-256 for downloads) and finalize the signature verifier themselves.

run() in main.rs had grown to 370 lines and ~62 branches. Its callbacks
move unchanged into register_settings, register_source_actions,
register_preview (with a flat show_preview helper), register_updates and
start_polling, following register_drive_checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reclaim Ready Ready Preview Nov 25, 2026 7:00am UTC

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 86cd4d37-783a-4ed3-aa90-255a72eb2d46
Commits

Reviewing files that changed from the base of the PR and between 5eb7c7a and 7f6a40b.

Files selected for processing: 2

  • src/main.rs
  • src/updater.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@sudo-py-dev
sudo-py-dev merged commit 3c0af4d into main Nov 25, 2026
8 checks passed
@sudo-py-dev
sudo-py-dev deleted the refactor/updater-stream-and-run branch November 25, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant