Skip to content

fleet-proxy(udp-forward): reject duplicate scalar flags in fleet-udp-forward (#6139) - #6145

Merged
dezren39 merged 2 commits into
mainfrom
queue/9936-6139-udp-forward-dup-flags
Nov 5, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/9936-6139-udp-forward-dup-flags

Conversation

@dezren39

@dezren39 dezren39 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #6139 (queue task 9936).

fleet-udp-forward's hand-rolled parser assigned scalar flags unconditionally, so a repeated --proxy/--bind/--target/--ports silently 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)

Verification

  • Reproduced pre-fix on the real binary at main 31ee14f: --target first.example --target second.example --ports 47998 served -> second.example:47998; duplicate --proxy served via the second proxy.
  • Post-fix probes: all four duplicate shapes exit 2 naming the flag and bind nothing; single-value control still serves; repeated --map still accumulates both forwards; --help unchanged (exit 0).
  • 11 new bin unit tests pin each duplicate shape, the any-position duplicate, and the --map / single-value / --help / missing-value / invalid---bind controls.
  • cargo test -p fleet-proxy green on the laptop (45 lib + 11 bin passed); cargo fmt --check clean.
  • Note: cargo clippy -p fleet-proxy cannot 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.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…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).
@dezren39
dezren39 requested a review from a team as a code owner November 5, 2026 07:56
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f750863d-d454-4f0b-9937-d03fb60a9332
Commits

Reviewing files that changed from the base of the PR and between a32b39c and 83c7ae6.

Files ignored due to path filters: 1

  • pkgs/fleet/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 2

  • pkgs/fleet/crates/fleet-proxy/Cargo.toml
  • pkgs/fleet/crates/fleet-proxy/src/bin/fleet-udp-forward.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T08:06:19.650628Z 83c7ae6 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
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.

fleet-proxy(udp-forward): fleet-udp-forward silently overwrites duplicate scalar flags — last --target/--proxy/--bind/--ports wins

1 participant