Skip to content

find: reject invalid -newerXY predicates like GNU - #784

Merged
sylvestre merged 1 commit into
uutils:mainfrom
l46983284-cpu:fix/find-unknown-newerxy-predicate
Jul 26, 2026
Merged

find: reject invalid -newerXY predicates like GNU#784
sylvestre merged 1 commit into
uutils:mainfrom
l46983284-cpu:fix/find-unknown-newerxy-predicate

Conversation

@l46983284-cpu

Copy link
Copy Markdown
Contributor

Summary

find accepted invalid predicates such as -neweraBcmty because the -newerXY parser matched a valid prefix instead of the whole argument. GNU find reports those as unknown predicates.

This change:

  • anchors -newerXY matching so only exact X∈{a,B,c,m} / Y∈{a,B,c,m,t} forms parse
  • reports unknown predicates with GNU-style wording: unknown predicate \…'` (as in the issue sample)
  • adds unit + integration coverage for the issue bug(find): Invalid predicates accepted #782 cases
  • fixes a pre-existing unit test that incorrectly glued -follow -newerXY into one argv token (that only worked while the regex was unanchored)

Note: open PR #724 only rewords the unknown-predicate message for ordinary unrecognized args. This PR also fixes the real #782 root cause (prefix match on -newerXY) and uses the GNU backtick/apostrophe quote shape from the issue.

Test plan

  • cargo test --lib (227 passed)
  • cargo test --test test_find invalid_newerxy_predicate_is_rejected
  • Integration harness covers find -neweraBcmty . failing with unknown predicate \-neweraBcmty'`

Fixes #782

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.88%. Comparing base (f38dbe5) to head (f483825).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/find/matchers/mod.rs 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #784      +/-   ##
==========================================
- Coverage   91.89%   91.88%   -0.01%     
==========================================
  Files          35       35              
  Lines        7217     7233      +16     
  Branches      376      376              
==========================================
+ Hits         6632     6646      +14     
- Misses        442      444       +2     
  Partials      143      143              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Commit dc04cfa has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 417 / FAILED: 77 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 416 / FAILED: 78 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + tests/find/refuse-noop

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 315 / PASSED: 267 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 267 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +2
  PASSED: +0
  FAILED: +2

New test failures (2):
  - gnu/files0_from_ok
  - gnu/okdir_path_relative

@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing l46983284-cpu:fix/find-unknown-newerxy-predicate (f483825) with main (f38dbe5)

Open in CodSpeed

@HackingRepo

HackingRepo commented Jul 26, 2026

Copy link
Copy Markdown

one job fails because of intermittent issues https://github.com/uutils/findutils/actions/runs/29574082323/job/87867034162

The -newerXY parser used an unanchored regex, so tokens such as
-neweraBcmty were accepted as a truncated -neweraB. Require an exact
-newerXY match, report unknown predicates with GNU wording, and cover
the issue uutils#782 cases in unit and integration tests.

Signed-off-by: Alex Chen <l46983284@gmail.com>
@sylvestre
sylvestre force-pushed the fix/find-unknown-newerxy-predicate branch from dc04cfa to f483825 Compare July 26, 2026 15:01
@github-actions

Copy link
Copy Markdown

Commit f483825 has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 417 / FAILED: 77 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 416 / FAILED: 78 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + tests/find/refuse-noop

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6

New test failures (1):
  - gnu/okdir_path_empty

Test improvements (1):
  + gnu/files0_from_ok

@sylvestre
sylvestre merged commit 3f9926c into uutils:main Jul 26, 2026
20 of 23 checks passed
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.

bug(find): Invalid predicates accepted

3 participants