Guard find -fprint/-fprintf/-fls (they write to a file) - #151
Merged
Conversation
These actions write find's output to a file, truncating it — the same destructive effect as a `> file` redirect, which Dippy already asks on. They were grouped with -print/-printf/-ls (stdout, safe) by name, but the `f` prefix means 'file'. Route them to ask alongside -delete. Fixes #150.
ldayton
added a commit
that referenced
this pull request
Jun 8, 2026
find's -fprint/-fprint0/-fprintf/-fls write find's output to the file that follows them, the same effect as a `> file` redirect. #151 routed them to a blanket ask; this surfaces the file argument as a redirect_target (the sort -o pattern) so the usual redirect rules apply: deny-redirect hard-blocks the path, allow-redirect pre-approves it, and an unmatched write defaults to ask — identical to the equivalent `> file` redirect. -delete/-exec/-ok handling is unchanged. A code comment notes the one known limitation: when a write is combined with -delete/-exec, the earlier branch returns first, so the target isn't separately gated (degrades to ask, never weaker). Adds TestFindFileWriteRedirectRules covering default->ask, deny-redirect->deny, allow-redirect->approve, and parity with the `>` redirect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #150.
find's-fprint,-fprint0,-fprintf, and-flswrite find's output to a file, truncating it — the same destructive effect as a> fileredirect, which Dippy already guards. They'd been grouped with-print/-printf/-lsas safe "print actions", but those write to stdout; thefprefix means file.This was an inconsistency: Dippy asks on one syntax and silently allows the other for the identical effect.
find . > /etc/hostsfind . -fprint /etc/hostsfind . -print(stdout)Changes
find.py: route-fprint/-fprint0/-fprintf/-flstoask, alongside-delete.test_find.py: move those four out of the "Print actions (safe)" cases (they were asserted approved) into the file-writing group, expectingask.Surfaced while investigating #130 (the
-deletecase, which was already guarded).Full suite: 11001 passing.