Repository navigation
fix(review): harden stale, un-revisited code paths across engine/persistence/remote/platform - #8
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 passgo test -race ./backend/...clean.Fixes (with tests)
🔴 Critical / High
engine/scheduler.go—Close()nowsync.Once-guarded; double-close no longer panics.engine/diskfree_{unix,windows}.go— free-space math computed inuint64and saturated toMaxInt64, so a large/odd filesystem can't overflow into a bogus negative.persistence/rss_feeds.go— a zeroLastPolledwas serialized as year-1 (-62135596800); now stored as0and round-tripped back to a true zero time. Also floorsinterval_mininUpdatelikeCreatedoes.persistence/users.go— deleting a user who granted access to others violated thegranted_byFK; 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'sIsGlobalUnicastreports 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 whenEvalSymlinks(saveTo)errors for a reason other than not-exist.updater/install_source.go— normalize paths on both sides of the dpkg.listmatch and cap the read, so a symlinked //usr/localinstall isn't misclassified as manual.notifications/beeep_notifier.go— hold the lock across theAppNameset andNotify(data race).tray/gnome_linux.go,tray/tray_other.go,logging/logging.go— log swallowed errors + consistentLookPath; bounded wait for systray teardown; log dir created0o700.Testing
go test -race -count=1 ./backend/...— all packages pass.go vet ./backend/...— clean.Out of scope (flagged for follow-up)
engine/anacrolix.godoesn't assertlen(bitmap) == (NumPieces+7)/8before 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