Repository navigation
fleet-proxy(udp-forward): reject duplicate scalar flags in fleet-udp-forward (#6139) - #6145
Conversation
…forward parseShell-style silent last-wins: repeating --proxy/--bind/--target/--ports silently overwrote the earlier value, so a script-concatenated duplicate could retarget the forwarder or re-point the CONNECT-UDP endpoint (#6139). Extract the parse loop into a pure parse_args_inner returning the usage error as a string (mirroring fleet-queue #5939), and reject a second occurrence of any scalar flag with 'argument --<flag>: duplicate flag' (stderr + usage, exit EXIT_USAGE=2) before anything binds. --map stays repeatable and accumulates; --help keeps short-circuiting where it appears; single-occurrence invocations parse exactly as before. 11 new bin unit tests pin each duplicate shape, the any-position duplicate, and the --map / single-value / --help / error controls. Reproduced pre-fix on the real binary (dup --target served the second host, dup --proxy served via the second proxy); post-fix all four duplicate shapes exit 2 naming the flag and the controls still serve. cargo test -p fleet-proxy green (45 lib + 11 bin).
|
Warning Review limit reachedYou'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 52 minutes. View limit details
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. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc62ad7f6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…6139) Codex review on PR #6145 (P1): the parser tests were fixed examples only, and the repo testing doctrine requires property-based coverage for parsers with meaningful invariants. Add proptest (1.12, the version pkgs/id and fleet-queue use) as a fleet-proxy dev-dependency and three generated tests whose oracle is the invariant / a model of the generated invocation: - duplicate_scalar_rejected_in_any_position: any scalar flag twice, interleaved anywhere among valid fillers and --map units, errors with exactly 'argument --<flag>: duplicate flag'. - distinct_scalars_parse_to_the_model: each scalar at most once, in generated layouts, parses to exactly the modeled fields. - help_short_circuits_but_never_excuses_an_earlier_duplicate: --help before the repeat parses as help; a duplicate completed before --help still errors. The example tests stay as smoke coverage. cargo test -p fleet-proxy green: 45 lib + 14 bin.
Fixes #6139 (queue task 9936).
fleet-udp-forward's hand-rolled parser assigned scalar flags unconditionally, so a repeated--proxy/--bind/--target/--portssilently overwrote the earlier value — a script-concatenated duplicate could retarget the forwarder or re-point the CONNECT-UDP endpoint with no error.Change (one file:
pkgs/fleet/crates/fleet-proxy/src/bin/fleet-udp-forward.rs)parse_args_innerreturning the usage error as aString, mirroring fleet-queue's fleet(queue): repo-queue client parser silently overwrites duplicate flags, accepts --dry-run=false as true, and silently defaults a non-numeric --limit #5939 pattern, so rejection shapes are unit-testable.argument --<flag>: duplicate flagvia the existingfail()path (stderr + usage, exitEXIT_USAGE= 2), before anything binds.--mapstays repeatable and accumulates;-h/--helpkeeps short-circuiting exactly where it appears; single-occurrence invocations parse exactly as before (defaults still applied inmain).Verification
--target first.example --target second.example --ports 47998served-> second.example:47998; duplicate--proxyserved via the second proxy.--mapstill accumulates both forwards;--helpunchanged (exit 0).--map/ single-value /--help/ missing-value / invalid---bindcontrols.cargo test -p fleet-proxygreen on the laptop (45 lib + 11 bin passed);cargo fmt --checkclean.cargo clippy -p fleet-proxycannot run on the laptop right now — pre-existing E0514 serde/rustc version skew in the shared target dir, failing on untouched crates (fleet-config,fleet-proxy-proto) before reaching this change. CI clippy is unaffected by that local artifact state.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.