Repository navigation
Review batch: CLI validation, replay read-only, export safety, docs and CI - #171
Merged
Merged
Conversation
derive_flow_hint compared the source port against `src_port_base + num_flows` as a u16. Args::validate accepts `src_port + flows - 1 <= u16::MAX`, so `--src-port 65520 --flows 16` (and `--src-port 65535` with the default single flow) computed 65536: a debug-build panic in the receiver thread, and in release a wrapped bound of 0 that emptied the window, so every reply was reported as unknown-flow and dropped as 100% loss. Compare the offset in u32 instead, and cover the boundary at the receiver rather than only in Args::validate.
`--theme` had no value parser or validation. An unknown name fell through Theme::by_name to the default theme with no message, and quitting then persisted that default over the theme the user had saved, so a one-letter typo silently discarded the preference. Split Theme::by_name into an Option-returning resolve plus a Theme::is_known_name predicate over the same name/alias table, and reject unknown values in Args::validate with the offending name and the valid list.
--diff declared conflicts with targets and --replay did not, and the replay/diff validation block only rejected --pmtud and --jumbo. So `ttl --replay trace.json 1.1.1.1 -c 5 --flows 4` was accepted while the target, round count, flows, port, rate, size, protocol, interface and source address were all silently ignored: run_replay_mode reads none of them. Give --replay the same targets conflict as --diff, and reject deviations from the probe defaults in either mode with an error naming the flag. Output and presentation flags (--json/--csv/--report/--theme/--wide/ --animate/--no-update-check/--replay-size-limit) still apply.
The `r` handler was unconditional while `p` and `o` were guarded. A session opened with --replay has no live epoch, so reset_stats blanked the hop table, dropped dest_ttl, cleared events and made the trace look live; pressing `e` afterwards exported an all-zero session over the recording. The static-replay status bar advertised the key. Gate reset and pause on the session having a live epoch, report "Replay is read-only" instead of a lying "Stats reset"/"Resumed", and drop the reset hint from the static-replay hint set. Factor the duplicated live-pause body out of `p` and Space, which also makes the badge follow the session's own paused flag rather than a separate copy.
1. The settings footer could never show `Enter select`: the popup is capped
at 48 columns and `popup()` budgets hints as width - 6, so the four pairs
(46 cells) never fit the 42-cell budget at any terminal size, even though
Enter is the modal's only action key. Widen the popup to 52.
2. A long status message removed every key hint. The message was fitted to
the full bar width and the remainder sized the hint line, so a 41-cell
export message at width 50 left 5 cells, which fits no pair. Reserve the
highest-priority hint before sizing the message, and cover the narrow
widths the old test skipped.
3. The target list padded hostnames with `{:<width$}`, which pads by chars
while `fit_text` bounds cells. A name of double-width characters
overflowed `row_width`, and the resulting whole-line truncation dropped
the loss and RTT columns. Pad by cells and size the name column in cells.
…sync Settings always opened the theme list at scroll 0 while the list shows five rows, so a theme picked with `t` before pressing `s` was off screen with no selection marker, and Up/Down only scrolled it back into view once the index walked into the first page. Initialise the scroll from the active index, and share one VISIBLE_THEMES constant with the render window and move_down instead of a third copy of 5. Adding a target while paused left the badge claiming PAUSED while the new session probed immediately. Propagate the pause to the session that just joined, so the badge and the engine agree; the poll now takes the session map and both call sites pass it.
…olve Two errors were reported in a way the user could not act on: * Both preference-save sites discarded the error (`let _ = final_prefs.save()`), so a read-only config directory silently lost the theme, display mode, API key and update-check changes. Warn to stderr with the failing path. * `--resolve-all` wrapped the whole loop in a generic "Failed to resolve targets", so with several targets there was no way to tell which name was broken. Add the per-host context the single-target path already had. * `--json -c 0` claimed `-c` was not set although it was: say that batch output needs a positive count and that `-c 0` runs until quit.
A hop's PTR record is controlled by whoever runs that address, and the hostname column is written verbatim. `=cmd|' /C calc'!A0.example` is a live formula to Excel and LibreOffice, which is CWE-1236 on the analyst's workstation. Prefix a leading =, +, -, @, tab or CR with an apostrophe so the cell stays literal, keeping the existing quoting rules (and so the field count) intact. Only hostname passes through escape_csv; every other column is numeric.
`atomic_write` canonicalised the destination unconditionally, so a planted `ttl-<target>-<timestamp>.json -> ~/.bashrc` in the directory the user exports from redirected the rename onto the link target, replacing an arbitrary user-writable file with trace JSON. Following a link is deliberate for preferences (dotfile config links must survive), so split the writer: exports use a non-resolving variant that refuses a symlinked destination outright, while Prefs::save keeps the canonicalising path and its existing test.
Four pub functions had no caller in src/, tests/ or examples/ and were kept alive only by #[allow(dead_code)]: Session::discovered_hops, Session::last_responding_hop, Session::first_nat_hop and probe::interface::get_interface_source_ip. They are part of the crate's public surface, so they constrained semver and documented filtering rules nothing consumed. ResponderStats::loss_pct goes too — its own doc called it inaccurate, Hop::loss_pct holds the real formula — along with the assertion that only exercised it. is-terminal 0.4 says in its own README that std::io::IsTerminal supersedes it as of Rust 1.70, and this crate's MSRV is 1.88. Switch the two call sites and drop the dependency.
The TUI set the key on its IxLookup; run_batch_mode and run_streaming_mode called IxLookup::new() and never loaded Prefs, so a key configured in Settings only helped interactive runs. After the 24 h IX cache expired, `-c 10 --json`, `--report`, `--stream-json` and `--daemon --prometheus` silently fell back to anonymous access, got rate limited, and exported `ix: null` for every responder — the scripting path the docs recommend the key for. Route all three modes through one build_ix_lookup(config, prefs) so they cannot drift again; PEERINGDB_API_KEY still wins inside the lookup.
* CHANGELOG 0.24.0 named an unreachable `--dns` server as the way to reproduce the cancelled-lookup fix. No such flag exists (only `--no-dns` and the system resolver); say "system resolver". * docs/FEATURES.md promised the replay progress bar shows an event count. It shows clock and speed, and the test that pins the label is named replay_label_shows_clock_and_speed_without_event_counts. * docs/FEATURES.md promised route-change history "with timestamps". RouteChange stores only from_ip, to_ip and at_seq, and the view renders "after N responses". The fourth item — the module header in src/probe/interface.rs claiming FreeBSD interface binding works — was fixed with the dead-code removal.
docs/INSTALL.md and docs/FEATURES.md tell packagers to build with `--no-default-features` to drop the startup update check and the update-informer dependency, but no CI leg ever built that configuration, so a change referencing update_informer outside its cfg block would ship green. Add a check and a clippy run for it to the build job.
lance0
force-pushed
the
fix/review-batch-2026-11
branch
from
November 12, 2026 18:40
f1d4306 to
b3610a3
Compare
The read-only guard keyed on the session having no live epoch, but an --animate replay draws into a fresh Session::new, which has one. Pressing r mid-playback blanked the hops and events, later events rebuilt only part of the trace, and an e export then wrote that partial session. Refuse the reset whenever a replay is active, not only for a static replay.
Propagating the pause to the added target also ran when the reply said the target already existed. Re-adding a running target while viewing a paused one then silently paused the running target. For an existing target, only select it and take the badge from that session's own paused flag.
The replay/diff probe-flag check compared the raw -p value against "auto", while live mode lowercases it. So `--replay x.json -p AUTO`, a no-op default, was rejected. Compare the lowercased protocol instead.
The new warning printed the error with {}, which for anyhow shows only the
outermost message: a read-only config directory reported "Failed to create
temporary save in <dir>" without the reason, and a failed create_dir_all
reported the OS error without any path. Give create_dir_all a path context
and print the whole chain.
# Conflicts: # Cargo.lock
lance0
marked this pull request as ready for review
November 12, 2026 23:17
This was referenced Nov 13, 2026
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.
Batch of low-risk fixes from a deep review of the codebase. One commit per fix. No probing behaviour, packet layout, or shutdown ordering changes: the two high-severity findings from the review are deliberately not here (see below).
What changes
CLI validation
derive_flow_hintcompares the flow-port window inu32:--src-port 65520 --flows 16(and--src-port 65535) is accepted by validation but overflowed theu16bound to an empty window — a debug-build panic in the receiver thread, 100% loss in release.--themevalues are rejected with the offending name and the valid list, instead of silently starting in the default theme and then persisting that default over the saved one. Documented aliases (mono,futuristic,hacker,mocha,tokyo,tokyonight) still work.--replayand--diffreject probe-only flags (positional target,-c,-i,-m,--timeout,-p,--port,--fixed-port,--flows,--src-port,--rate,--size,--dscp,--interface,--source-ip) that those modes accepted and silently ignored. Output and presentation flags are unaffected.Replay is read-only
randpon a session loaded from a file used to blank the hop table, dropdest_ttland clearevents, so the nexteexport wrote an all-zero session over the recording. They now reportReplay is read-only, and the static-replay status bar no longer advertises reset.TUI correctness
Enter select(it never fit at the 48-column cap), a long status message keeps the highest-priority hint instead of blanking the row, and target rows pad by terminal cells so a double-width hostname no longer truncates the loss and RTT columns.Errors and export safety
--resolve-allnames the host that failed to resolve;-c 0with a batch output mode says a positive count is required instead of claiming-cwas not set.=,+,-,@, tab or CR is prefixed with an apostrophe (CWE-1236).--json,--csv,--report,--stream-jsonand--daemon, not just the TUI, so cache refreshes in headless runs are no longer rate limited intoix: null.Cleanup, docs, CI
pubhelpers andResponderStats::loss_pct; replaceis-terminalwithstd::io::IsTerminal(std since 1.70, crate MSRV 1.88).--dnsflag exists, the replay progress bar has no event count, route changes carry a response count rather than a timestamp, and FreeBSD interface binding is not implemented.--no-default-featuresconfiguration, which no leg compiled before.Deliberately not included
-ccompletion cancels the shared token (high): the first target to finish its rounds cancels every other engine and makes the receiver flush in-flight probes as timeouts, truncating multi-target runs and inventing loss. Changes shutdown ordering; wants a live testbed.-ccheck. Same reason: raw ICMPv6 socket behaviour that cannot be exercised withoutCAP_NET_RAW.LateReplyreplay accounting, pending probes surviving a stats reset, UDP quotes containing only the transport header, and PMTUD leaving DF set on the shared socket plus taking a write lock every tick. Each changes observable probe accounting, display bounds or export contents.Verification
Each behavioural fix has a regression test, and three of them were confirmed to fail against the pre-fix code before being kept (target padding, theme scroll, export symlink). Runtime checks through the built binary:
--theme dracul,--json -c 0,--replay x.json -c 5,--replay x.json 1.1.1.1, a read-onlyXDG_CONFIG_HOME(preference warning now printed with the path), and colour suppressed on a pipe with colour restored on a pty.Not verified here: anything needing raw sockets (
CAP_NET_RAWunavailable in this environment) and the TUI render loop itself (TERM=dumb, no interactive terminal).