Skip to content

fix(review): harden stale, un-revisited code paths across engine/persistence/remote/platform - #8

Merged
exec merged 1 commit into
mainfrom
claude/codebase-deep-review-rrfxjt
Jun 23, 2026
Merged

exec merged 1 commit into
mainfrom
claude/codebase-deep-review-rrfxjt

Conversation

@exec

@exec exec commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

A deep review of files still sitting at the initial drop — the ones that missed the recent run of fix(...) hardening commits — surfaced bugs matching patterns already fixed elsewhere in the tree (zero-time serialization, cascade-on-delete, double-close safety). All fixes are verified against the source, covered by tests, and pass go test -race ./backend/... clean.

Fixes (with tests)

🔴 Critical / High

  • engine/scheduler.go — Close() now sync.Once-guarded; double-close no longer panics.
  • engine/diskfree_{unix,windows}.go — free-space math computed in uint64 and saturated to MaxInt64, so a large/odd filesystem can't overflow into a bogus negative.
  • persistence/rss_feeds.go — a zero LastPolled was serialized as year-1 (-62135596800); now stored as 0 and round-tripped back to a true zero time. Also floors interval_min in Update like Create does.
  • persistence/users.go — deleting a user who granted access to others violated the granted_by FK; now nulled in the same transaction before the delete.
  • api/safefetch.go — SSRF blocklist missed CGNAT (100.64.0.0/10) and IPv6 6to4/Teredo (Go's IsGlobalUnicast reports those as global); now blocked via an allow-global-only baseline.
  • notifications/linux_notifier.go — a dead cached D-Bus connection made notifications fail forever; now dropped+closed on send error so the next call reconnects.

🟡 Medium / 🟢 Low

  • remote/certs.go — serialize generation + atomic (temp→rename) PEM writes to avoid a mismatched cert/key pair; validity 10y→397d with expiry-based regeneration; link-local addresses excluded from SANs.
  • engine/verify_snapshot.go — Lstat (don't follow symlinks) + fold file mode/type into the digest; log non-not-exist stat errors instead of swallowing.
  • engine/safepath.go — fail closed on a delete when EvalSymlinks(saveTo) errors for a reason other than not-exist.
  • updater/install_source.go — normalize paths on both sides of the dpkg .list match and cap the read, so a symlinked / /usr/local install isn't misclassified as manual.
  • notifications/beeep_notifier.go — hold the lock across the AppName set and Notify (data race).
  • tray/gnome_linux.go, tray/tray_other.go, logging/logging.go — log swallowed errors + consistent LookPath; bounded wait for systray teardown; log dir created 0o700.

Testing

  • go test -race -count=1 ./backend/... — all packages pass.
  • go vet ./backend/... — clean.

Out of scope (flagged for follow-up)

engine/anacrolix.go doesn't assert len(bitmap) == (NumPieces+7)/8 before trusting a fast-resume bitmap (it bounds-checks per-access but doesn't validate length up front). It falls outside the stale-file set reviewed here.

🤖 Generated with Claude Code


Generated by Claude Code

…istence/remote/platform

A deep review of files still at the initial drop (those that missed the
recent hardening pass) surfaced bugs matching patterns already fixed
elsewhere. Fixes, with tests:

engine:
- scheduler: guard Close() with sync.Once (double-close no longer panics)
- diskfree (unix+windows): compute free space in uint64 and saturate to
  MaxInt64 so a huge/odd filesystem can't overflow into a negative result
- verify_snapshot: stat with Lstat (don't follow symlinks), fold file
  mode/type into the digest, and log non-not-exist stat errors instead of
  swallowing them
- safepath: fail closed on a delete when EvalSymlinks(saveTo) errors for a
  reason other than not-exist

persistence:
- rss_feeds: serialize a zero LastPolled as 0 (not year-1) and round-trip
  it back to the zero time; floor interval_min in Update like Create
- users: null out torrent_access.granted_by in the same tx before deleting
  a user, so deleting a granting user no longer violates the FK

remote:
- certs: serialize cert/key generation and write each PEM atomically
  (temp + rename) to avoid a mismatched pair; drop validity 10y -> 397d
  and regenerate when expiring; exclude link-local addrs from SANs

api:
- safefetch: block CGNAT 100.64.0.0/10 and the IPv6 6to4/Teredo transition
  ranges (Go's IsGlobalUnicast reports those as global), via an
  allow-global-only baseline

platform/desktop:
- linux notifier: drop+close a dead cached D-Bus conn on send error so the
  next call reconnects instead of failing forever
- beeep: hold the lock across the AppName set and Notify (data race)
- updater: normalize paths on both sides of the dpkg .list match and cap
  the file read, so a symlinked/usr-local install isn't misclassified
- tray gnome: log swallowed errors and resolve gnome-extensions via
  LookPath consistently; tray_other: wait (bounded) for systray teardown
- logging: create the log dir 0o700 (logs hold names/paths/peer IPs)

https://claude.ai/code/session_01Y9QdLdcasfGE3rNVFMAH3q
@exec
exec merged commit 410206d into main Jun 23, 2026
@exec
exec deleted the claude/codebase-deep-review-rrfxjt branch June 25, 2026 18:43
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.

2 participants