Repository navigation
Close six holes a review found: aliases, find, wrappers, deep code, long patterns, canonical names - #291
Merged
Conversation
A word of `alias` holding an expansion (`alias x="$CMD"`, `alias x="$(curl …)"`) was dropped from the aliases the line defines, so a later call of it resolved to an unknown bare name and the line was safe. Such a word may define any alias with any value, so the definition is a script the guard does not read: it is `unknown`, as `eval "$CMD"` is. The aliases the same command defines in full are still read, so a call of one is judged by what it runs. Fixes #285
`find`'s own actions that write a file were never read by the rules, so `find . -fprint ~/.bashrc` and `find . -fprintf /etc/cron.d/x '…'` were safe while `find . > ~/.bashrc` is `overwrite`; `effect` already called them writes. Each file is now judged as a redirect's is, read from the expression as `find` reads it, so a test's value and the words an `-exec` runs are not taken for one. Fixes #287
`firejail`, `fakeroot`, `faketime`, `bwrap`, `proot` and `entr` run the command after their options, but none was a wrapper the guard knew, so `firejail rm -rf ~` was safe while `nice rm -rf ~` is a delete. Each now runs its tail, read past its own options. bubblewrap and proot map the file system the command sees, so a path it names may be any folder: the command is judged as written and the line is unreadable as well. `man -P CMD`, `man -H CMD` and fzf's `--preview CMD` hand a command to a shell, which is read as a script; man's short options are read as getopt bundles them (`-aP CMD`). A key binding of fzf may run any command, which is not read. Fixes #288
`read` stops at the first node past `MAX_TREE_DEPTH` and says `deep`, but `understand` walked the whole tree with no limit, so code nested past it came back `Understood` with the acts after the deep part missing. The strict reader now refuses a node past the same depth, so `deep` code is never understood, which the crate promises. The shell guard was not fooled, since it reads `deep` too, but any other caller would have been. `tests/robust.rs` now holds the 2 000-deep case to `NotUnderstood`, and holds every deep shape the reader does not walk whole to it as well. Fixes #289
Whether a pattern can pick a file a tool runs on its own was asked once for every part the pattern may start at, each time in time linear in the pattern, so `cp x src/a*/a*/…/x` with a 6 KB operand took 6.7 s and a `**/` run of 60 KB took 15 s, though every input is within the limits. `picks` builds its table from the end of the pattern, so one table now answers every start, and the check that the rest is all globstars is kept as the table is built. The same lines take tens of milliseconds. The shell guard's timing tests hold the `a*/` and `**/` shapes to linear time, and `tests/posix_wildcards.rs` pins their answers in every build. Fixes #286
Core compared names character by character, so a protected folder named `café` was missed as `cafe` plus a combining accent, the spelling HFS+ keeps on disk; APFS and HFS+ open both as one file. The home directory, the sensitive places and the protected paths now compare by canonical equivalence, with Unicode 17.0's decompositions and combining classes in `src/canonical.rs`, and a pattern matches either spelling (`caf?` picks `café` both ways). Every place that reads this fails closed on a match too many; the workspace still compares as spelled. The file guard had pinned the old answer as a limit; its case moves to `tests/cases/protected.cases` with `write_protected`, and the design pages say how names compare. Fixes #290
This was referenced Nov 7, 2026
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.
A full review of the workspace found six bugs, five of them a line judged safe or a crafted line that took seconds. Each is fixed in its own commit, with the case lines that were judged wrong.
alias x="$CMD"; x) was dropped and its call was safe. The definition is nowunknown; aliases defined in full on the same command are still read. Fixes An alias whose value is only known when it runs is judged safe #285.a*/operand, 15 s for 60 KB of**/). One table now answers every start of the pattern; both shapes are held to linear time intests/timing.rs. Fixes A write into a long wildcard pattern takes time in the square of its parts #286.find -fprint,-fprint0,-flsand-fprintfwrote files the rules never read. Each file is judged as a redirect's is. Fixes find's -fprint, -fprint0, -fls and -fprintf write a file the rules never read #287.firejail,fakeroot,faketime,bwrap,proot,entr,man -P/-Hand fzf's--previewhid the command they run. Each is now read; bwrap and proot, which map the file system, are unreadable as well. Fixes Sandboxes and runners that run their tail hide the command they run #288.caféascafeplus a combining accent, as HFS+ stores it). Core now compares by canonical equivalence with Unicode 17.0 tables incrates/core/src/canonical.rs, only where matching too much fails closed. The file guard's case that pinned the old answer as a limit moves to its protected cases. Fixes A protected name is missed in its other canonical spelling #290.Not changed, on purpose:
hash -p /tmp/x ls; lsstays safe inclassify, asPATH=/tmp lsdoes, since the guard judges a bare name by its name.The fixes were reviewed twice by an independent reviewer. The first pass found five gaps: the
**/shape was still quadratic, man had other option spellings, the?direction of canonical matching was missing, the alias fix dropped the aliases defined in full beside the unread one, and bwrap's--level-prefixwas misread. All five are fixed here, and the second pass found nothing new.just verifyEvery recipe passes on the last commit, and each earlier commit passes clippy on its own.