Skip to content

fix(find): honor -print0, support negated -type, and fail on dangling -not - #1953

Merged
chaliy merged 1 commit into
mainfrom
2026-06-05-propose-fix-for-find-command-vulnerability
Jun 5, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-06-05-propose-fix-for-find-command-vulnerability

Conversation

@chaliy

@chaliy chaliy commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Close a fail-open compatibility gap where -print0, -not/! and negated -type were parsed but ignored, causing scripts relying on exact find semantics to get incorrect results.
  • Ensure find behavior is predictable for callers that depend on NUL-delimited output, negation, and error-on-missing-predicate semantics.

Description

  • Added print0 and negate_type to FindOptions and updated parse_find_args to set these when -print0, -not/! and -type with preceding negation are used, and to return an error on a dangling -not predicate (missing operand).
  • Updated find_recursive to honor opts.print0 when emitting paths and to apply opts.negate_type when evaluating -type predicates.
  • Ensured collect_find_plan_data constructs a temporary FindOptions preserving negation flags and default print0=false for planning.
  • Added regression integration tests in crates/bashkit/tests/integration/find_multi_path_tests.rs for -print0, negated -type, and a dangling -not case.

Testing

  • Ran cargo fmt --check and it passed.
  • Ran cargo test -p bashkit --test integration find_ -- --nocapture and the targeted integration tests passed (15 passed, 0 failed).
  • Ran cargo clippy -p bashkit --test integration -- -D warnings and it completed without warnings.

Codex Task

Copilot AI review requested due to automatic review settings June 5, 2026 19:49

Copilot AI 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.

Pull request overview

This PR tightens find builtin semantics in crates/bashkit/src/builtins/ls/find.rs to avoid “parsed-but-ignored” behavior by honoring -print0, supporting negation for -type via -not/!, and failing closed on a dangling -not. It also adds integration coverage to prevent regressions.

Changes:

  • Added print0 and negate_type to FindOptions, updated argument parsing, and added an error for trailing -not.
  • Updated recursive traversal/output to emit NUL delimiters when -print0 is set and to apply negate_type during -type evaluation.
  • Added integration tests for -print0, negated -type, and dangling -not.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/bashkit/src/builtins/ls/find.rs Implements -print0, -not/! handling for -type, and fail-closed parsing for dangling -not.
crates/bashkit/tests/integration/find_multi_path_tests.rs Adds regression tests for NUL-delimited output, negated -type, and dangling -not error behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +115 to +121
"f" | "d" | "l" => {
opts.type_filter = Some(t.chars().next().unwrap());
if negate_next {
opts.negate_type = true;
negate_next = false;
}
}
Comment on lines +166 to +168
"-print0" => {
opts.print0 = true;
}
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 3300625 Commit Preview URL Jun 05 2026, 08:18 PM

@chaliy
chaliy merged commit 4573c82 into main Jun 5, 2026
36 checks passed
@chaliy
chaliy deleted the 2026-06-05-propose-fix-for-find-command-vulnerability branch June 5, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants