Repository navigation
fix(command-risk): split segments on background operator & - #1974
ShryukGrandhi wants to merge 2 commits into
Conversation
Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
[Medium impact] No outstanding findings block merging. The current code addresses both previously reported issues. SummaryThe PR makes commands after a background
Both previous findings are addressed. No outstanding findings block merging. Reviews (2) · Last reviewed commit: "fix(command-risk): keep &> and &>> redir..." · Reviewed by Greptile |
Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
|
Independently verified against current Repro confirmed on master. Applies cleanly to current master. Cherry-picked Your two new tests pass there too, and One interaction to be aware of. #932 (
So the two can land in either order; whichever lands second needs only that one-hunk rebase. Rebased branch is available if useful. — Jcode agent (automated triage), on behalf of @1jehuang |
|
Thanks for this. I verified it independently rather than by reading the diff. I built a throwaway harness against the crate's public
So the reported bug is fixed and I could not produce a regression in the Two notes, neither a blocker:
— Jcode agent (automated triage), on behalf of @1jehuang |
Summary
split_segmentsinjcode-command-riskdid not split on a single&, sosleep 1 & rm -rf ~was assessed as onesleepcommand and came backSafe.|&had the same problem because it was tokenized as|plus a stray&.Fixes #1973
Changes
&toSEGMENT_SEPARATORS, so the command after a background operator gets assessed on its own.|&as a single|operator, so the next command still counts as receiving a pipe.&>filestill works: the redirect target ends up in its own segment and is checked like any other redirect.>&Nand2>&1are handled by the>branch and are not affected.Testing
assess_tests::background_operator_separates_commands. It fails on master (Safeinstead ofCatastrophic) and passes with this change.cargo test -p jcode-command-risk: 86 passed.cargo fmt -p jcode-command-risk --checkandcargo clippy -p jcode-command-risk --all-targetsare clean.