Skip to content

Gate find -fprint/-fprintf/-fls targets through redirect rules#152

Merged
ldayton merged 2 commits into
mainfrom
lily/find-fprint-redirect-targets
Jun 8, 2026
Merged

Gate find -fprint/-fprintf/-fls targets through redirect rules#152
ldayton merged 2 commits into
mainfrom
lily/find-fprint-redirect-targets

Conversation

@ldayton

@ldayton ldayton commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Follow-up to #151, doing it properly.

#151 routed find's -fprint/-fprint0/-fprintf/-fls to a blanket ask. That closed the allow→ask hole, but it didn't make them behave like the > file redirect they're equivalent to — it ignored the user's redirect rules:

User config find . > FILE -fprint FILE after #151 -fprint FILE here
deny-redirect /etc/** deny ask (rule ignored) deny
allow-redirect /tmp/** allow ask (rule ignored) allow
(none) ask ask ask

Change

These actions write find's output to the file that follows them, so surface that file as a redirect_targets entry — the same pattern sort -o FILE already uses. The analyzer then matches it against match_redirect, so deny-redirect hard-blocks, allow-redirect pre-approves, and an unmatched write defaults to ask. The result is identical to the equivalent > file redirect.

-delete, -exec, and -ok handling is unchanged.

Tests

Added TestFindFileWriteRedirectRules: default→ask, deny-redirect→deny, allow-redirect→approve, -fls/-fprintf gated too, and a check that -fprint FILE resolves identically to > FILE. The existing default-config cases (ask) still hold. Full suite: 11006 passing.

ldayton added 2 commits June 8, 2026 15:56
#151 made these file-writing actions ask, which closed the allow->ask
hole but treated them as a blanket prompt. They write to a file just like
a `> file` redirect, so surface the file argument as a redirect_target
(the sort -o pattern) instead. Now allow-redirect pre-approves and
deny-redirect hard-blocks the target, exactly matching `>` — and an
unmatched write still defaults to ask.
@ldayton ldayton merged commit 94b0e6b into main Jun 8, 2026
1 check 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.

1 participant