Skip to content

Harden reassembly, proxy, decoder, and TUI; add Parse→SQL resolution - #33

Open
iPeluwa wants to merge 3 commits into
sunng87:mainfrom
iPeluwa:harden/reassembly-proxy-tui
Open

Harden reassembly, proxy, decoder, and TUI; add Parse→SQL resolution#33
iPeluwa wants to merge 3 commits into
sunng87:mainfrom
iPeluwa:harden/reassembly-proxy-tui

Conversation

@iPeluwa

@iPeluwa iPeluwa commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Broad hardening pass over the capture data path, MITM proxy, decoder, TUI, and filter language, plus project-health gaps.

Stacks on #32. This branch builds on feat/session-save-replay, so it currently also shows that PR's two commits. Once #32 merges, this PR's diff reduces to the single hardening commit. Review the last commit for the changes proposed here.

Highlights

  • Capture path: connections now evict (close-grace sweep + LRU backstop) so a long tap of short-lived clients no longer leaks; reassembly resyncs past dropped-packet gaps instead of stalling; overlapping/re-segmented retransmits deliver every byte; TSO/GSO, IP fragments, kernel drops, snaplen truncation, and VLAN frames handled.
  • MITM proxy: PG17+ direct SSL (ALPN postgresql); GSS-refusal → SSLRequest re-dispatch; cancel-path upstream TLS; join! both legs for half-close; SNI from the upstream host; resilient accept loop. New in-process end-to-end test.
  • Decoder: prepared-statement SQL resolution so Bind/Execute show the query; decode-desync recovery; capped CopyData previews; CancelRequest pid/key; bounded, non-blocking output channel (no OOM, no relay stall).
  • TUI: fatal source errors surfaced on the splash + non-zero exit; scroll preserved across history-cap eviction; filter applies on Enter with Esc cancel-restore; no blank viewport leaving follow; source-panic isolation; :save self-overwrite guard; ~ expansion; Ctrl-C cancels input. New / text search with n/N and highlighting (: = command bar).
  • Filter language: ordered client.port comparisons; quote-terminated bare words; quoted port numbers.
  • Docs / project health: corrected man page and README; troubleshooting + sensitive-data notes; CI macOS/MSRV/audit; test-gated multi-platform release with checksums; PKGBUILD hygiene; CONTRIBUTING/SECURITY/CHANGELOG; replayable examples/demo-session.jsonl.

Verification

  • Test suite: 64 → 89 tests, all passing.
  • cargo clippy --all-targets clean; cargo fmt --check clean.
  • examples/demo-session.jsonl verified to replay.

Notes

  • The direct-SSL and GSS-refusal proxy paths are logic-reviewed and unit-tested on the cleartext path; a live PG17 client would be the ideal end-to-end confirmation.

iPeluwa added 3 commits July 17, 2026 14:15
Addresses a broad review of the capture data path, MITM proxy, decoder,
TUI, and filter language, plus project-health gaps.

Capture path (flow.rs, net.rs, capture.rs):
- Evict connections (close-grace tombstone sweep + LRU backstop) so a
  long-running tap of short-lived clients no longer leaks memory.
- Resync past an over-cap reassembly gap instead of stalling forever;
  deliver every byte of overlapping/re-segmented retransmits; keep the
  longer of duplicate out-of-order segments; keep the TCP Fast Open first
  byte; reset state on port-reuse SYNs; stop phantom connections from bare
  packets and duplicate RSTs.
- Handle TSO/GSO (IP total-length 0), drop non-first IP fragments, surface
  kernel drops and snaplen truncation, match VLAN frames, immediate mode.

MITM proxy (proxy.rs):
- Support PG17+ direct SSL (ALPN "postgresql"); re-dispatch the client's
  SSLRequest after a GSS refusal; probe upstream TLS on the cancel path;
  join both relay legs so half-closed peers finish; derive upstream SNI;
  keep serving through transient accept errors. Add an in-process E2E test.

Decoder (decode.rs):
- Resolve prepared-statement SQL so Bind/Execute show the query text.
- Recover from decode desync and give up cleanly after repeated failures;
  cap printable CopyData previews; show CancelRequest pid/key.
- Bound the output channel and drop-with-count via try_send behind an
  RwLock, so a wedged consumer can't OOM or stall the relay.

TUI + search (tui.rs):
- Surface fatal source errors on the splash and exit non-zero; preserve
  scroll across history-cap eviction; apply the filter on Enter and let Esc
  cancel-restore; fix the blank viewport when leaving follow; catch source
  panics; guard :save against the replay input; account for cleared events;
  expand ~ in paths; Ctrl-C cancels input; snapshot metrics once per frame.
- Add "/" text search with n/N navigation and match highlighting; ":" opens
  the command bar.

Filter language (filter.rs):
- Ordered client.port comparisons, quote-terminated bare words, and quoted
  port numbers accepted symmetrically with IPs.

Docs and project health:
- Correct the man page (-Y fatality, exit status, message.type vocabulary,
  new keys); README key table; troubleshooting and sensitive-data notes.
- CI macOS/MSRV/audit jobs; test-gated multi-platform release with
  checksums; PKGBUILD hygiene; CONTRIBUTING, SECURITY, CHANGELOG, and a
  replayable examples/demo-session.jsonl.

Test suite grows from 64 to 89; clippy and rustfmt clean.
@sunng87

sunng87 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

@iPeluwa let's get #32 merged first before this. Please check my comment in #32
Also there is MSRV test failure for this.

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