docs(fermata): the page lists the command holes left for the shell parser, each with a test
N-1b (a shell line ending in a backslash), S-1b (grep -fe clusters), R-1 (writes through a shell's positional arguments), R-2 (bash -oc pipefail), R-3 (PowerShell short switches) as known failures, and the echo-only positional argument as an over-denial. Command checks are marked best effort until the shell parser round. security-model.md says positional arguments are read only as printed. No src change.
This commit is contained in:
@@ -18,6 +18,8 @@ This is the largest limit for values fermata knows.
|
||||
|
||||
## Commands a rule does not see
|
||||
|
||||
Command checks are best effort, and will be rebuilt on a shell parser. What a program opens internally was never in fermata's scope.
|
||||
|
||||
The check reads the command's text, not what the shell makes of it.
|
||||
|
||||
- A substitution that builds the name, and a script that opens the file: `cat $(printf '.e%s' nv)`, `python -c "print(open('.env').read())"`, `sh run.sh`. (Test: `a_variable_a_substitution_and_a_script_hide_the_file_from_the_command_rules`.)
|
||||
@@ -31,6 +33,11 @@ The check reads the command's text, not what the shell makes of it.
|
||||
- A command run in one project does not meet another project's rules: `cat ../other/x` passes, while a Read of that file is stopped. (Test: `a_command_in_one_project_is_not_stopped_by_another_projects_rule`.)
|
||||
- A write by a verb off the writing list: `git clone https://example.invalid/x vendor/new`, `unzip a.zip -d vendor/new`, `tar cf vendor/new a.txt`, `python make.py vendor/new`, `perl -pi`, `awk -i inplace`. A glob over directories in the target (`touch vend*/new`) is not read either. (Test: `a_new_file_named_to_a_verb_off_the_writing_list_is_not_checked`.)
|
||||
- An output flag's value given with `=` or `:` (`tool -o=vendor/new`, `sort -o=vendor/new`, `Copy-Item a.txt -Destination:vendor\new`), and BSD's `sed -I`. (Test: `a_write_given_by_an_equals_sign_a_colon_or_sed_capital_i_is_not_checked`.)
|
||||
- A shell line that ends in a backslash: `bash -c 'cat "$1"; echo \' _ .env`. The check reads the arguments through a line it appends, and the backslash joins that line to `echo`. Bash prints the file. The gate form with `id_rsa` passes too. (Test: `a_shell_line_ending_in_a_backslash_hides_its_arguments`.)
|
||||
- A cluster where `f` comes before a final `e`: `grep -fe .env`, `rg -fe .env`, `sed -nfe .env`, `awk -fe .env`. The check takes `.env` for the pattern, while the program reads a pattern file named `e` and then reads `.env`. The gate forms with `id_rsa` pass too. (Test: `a_pattern_flag_after_a_file_flag_in_one_cluster_hides_the_file`.)
|
||||
- A write through a shell's arguments: `bash -c 'rm "$1"' _ a.txt`, `bash -c 'cp b.txt "$1"' _ vendor/new`, `sh -c 'rm "$0"' a.txt`, and the same with `mv`, `sed -i`, `touch` and `tee`. The arguments are read only as what the shell may print, so no write rule sees them. (Test: `a_write_through_a_shells_positional_arguments_is_not_checked`.)
|
||||
- A shell flag cluster with `o` or `O` before `c`: `bash -oc pipefail 'cat .env'`, `bash -Oc extglob 'cat .env'`. The check takes `pipefail` for the line. (Test: `a_shell_cluster_with_o_before_c_takes_the_options_value_for_the_line`.)
|
||||
- A PowerShell switch by a short form or another prefix: `pwsh -nol -c 'cat .env'`, `-noe`, `-i`, `-NoProf`, `-NonInter`, and `powershell` the same. The check takes the switch to hold a value, so it skips the `-c`. Only fermata's verdict is tested, since pwsh was not run. (Test: `a_powershell_switch_by_a_short_form_hides_the_command`.)
|
||||
|
||||
## Secret files fermata cannot mask
|
||||
|
||||
@@ -97,3 +104,5 @@ The guard stops a Write or Edit that adds a mask to a file. It does not cover th
|
||||
- A value flag of a tool other than `grep` and `rg`, or one off their list: `grep --color always .env a.txt` takes `always` as the pattern.
|
||||
|
||||
(Test for all five: `a_harmless_command_a_rule_still_stops`.)
|
||||
|
||||
- A shell's argument that its line only echoes or tests: `bash -c 'echo "$1"' _ .env`, `bash -c 'test -f "$1"' _ .env`. Every argument after the line is read as printed. (Test: `a_shell_argument_its_line_only_echoes_is_stopped`.)
|
||||
|
||||
@@ -46,7 +46,7 @@ Its false-positive rate is higher than Layer 1's, which is why it warns: masking
|
||||
|
||||
Stop the tool calls your rules name, and a Read of a secret file that fermata cannot mask. With `[policy.write]` on `.claude/**`, `Write .claude/settings.json` is denied. With `[policy.bash] deny = ["rm -rf /"]`, `Bash: rm -rf /` is denied. Without rules nothing is stopped, apart from the two gates below. Path patterns apply to the Read, Write and Edit tools (and Grep with a `path`, which counts as a Read), and command patterns match the text of a command. A `~/` in a tool's path is the home directory.
|
||||
|
||||
- **Commands that name a file.** A command is split into segments, and each word that names an existing file, an existing path with a separator, a path with `$`, `*` or `?` in it, or a file the command writes is checked. So `composer require vendor/package` and `git checkout build/fix` name nothing under a rule on `vendor/` or `build/`. The command line given to a shell (`bash rbash sh zsh dash ksh rksh mksh oksh pdksh ash yash osh fish csh tcsh nu elvish xonsh pwsh powershell cmd`, by a short flag cluster holding `c` such as `-ce`, `--command`, PowerShell's `-Command` by any abbreviation, or `cmd /c` and `/k`) and to `eval` is read as a command line of its own, when the flag stands among the shell's leading options (before a script's name, or PowerShell's `-File`). `eval`, `cmd` and PowerShell join the words after the flag; a POSIX shell's words after its line are its arguments and are read as what it may print, and `sudo env time nohup command exec timeout nice ionice stdbuf xargs busybox` before a verb do not hide it. A wrapper counts by its file name only as a bare word or an absolute path, so `./do .env` is a script called on the file. After an absolute path (`/home/me/env .env`) the next word still counts as a path, because that may be a script too. Which check depends on the segment's verb. A printing verb (`cat head tail less more bat nl tac cut sort uniq grep egrep fgrep rg awk sed strings xxd od hexdump base64 gc type get-content select-string`) meets the path rules and the read gate. A write meets `.botignore`, `[policy.write]` and `[policy.read]`, also for a file that is not there yet: a redirect's target, every path of `mv rm rmdir touch mkdir tee truncate shred set-content sc add-content ac out-file tee-object new-item remove-item rename-item move-item` and of `sed` with `-i` in any spelling, the last path of `cp ln install rsync scp copy-item` unless it is remote, `dd of=`, and the value of `-o` or `--output` on a verb that neither prints nor is metadata and on `sort`, `wget -O`, `cp -t`, `-Destination`, attached or not. A write does not meet the read gate, and a printing verb's write still counts as printing: `sed -i` and `sort -o` meet the gate. Any other verb (`source`, `python`, `chmod`) meets `.botignore` and `[policy.read]`. A metadata verb (`ls stat file test [ du which echo printf`, and `git status`, `git check-ignore`, `git ls-files`, `git commit`) given as a bare word meets nothing. So with `.env` in `.botignore`, `cat .env`, `cat ./.env; false` and `source .env` are denied, while `env`, `grep -r TOKEN .` and `git commit -m ".env loading"` pass.
|
||||
- **Commands that name a file.** A command is split into segments, and each word that names an existing file, an existing path with a separator, a path with `$`, `*` or `?` in it, or a file the command writes is checked. So `composer require vendor/package` and `git checkout build/fix` name nothing under a rule on `vendor/` or `build/`. The command line given to a shell (`bash rbash sh zsh dash ksh rksh mksh oksh pdksh ash yash osh fish csh tcsh nu elvish xonsh pwsh powershell cmd`, by a short flag cluster holding `c` such as `-ce`, `--command`, PowerShell's `-Command` by any abbreviation, or `cmd /c` and `/k`) and to `eval` is read as a command line of its own, when the flag stands among the shell's leading options (before a script's name, or PowerShell's `-File`). `eval`, `cmd` and PowerShell join the words after the flag; a POSIX shell's words after its line are its arguments and are read only as what it may print, so a write the line does to `"$1"` meets no write rule, and `sudo env time nohup command exec timeout nice ionice stdbuf xargs busybox` before a verb do not hide it. A wrapper counts by its file name only as a bare word or an absolute path, so `./do .env` is a script called on the file. After an absolute path (`/home/me/env .env`) the next word still counts as a path, because that may be a script too. Which check depends on the segment's verb. A printing verb (`cat head tail less more bat nl tac cut sort uniq grep egrep fgrep rg awk sed strings xxd od hexdump base64 gc type get-content select-string`) meets the path rules and the read gate. A write meets `.botignore`, `[policy.write]` and `[policy.read]`, also for a file that is not there yet: a redirect's target, every path of `mv rm rmdir touch mkdir tee truncate shred set-content sc add-content ac out-file tee-object new-item remove-item rename-item move-item` and of `sed` with `-i` in any spelling, the last path of `cp ln install rsync scp copy-item` unless it is remote, `dd of=`, and the value of `-o` or `--output` on a verb that neither prints nor is metadata and on `sort`, `wget -O`, `cp -t`, `-Destination`, attached or not. A write does not meet the read gate, and a printing verb's write still counts as printing: `sed -i` and `sort -o` meet the gate. Any other verb (`source`, `python`, `chmod`) meets `.botignore` and `[policy.read]`. A metadata verb (`ls stat file test [ du which echo printf`, and `git status`, `git check-ignore`, `git ls-files`, `git commit`) given as a bare word meets nothing. So with `.env` in `.botignore`, `cat .env`, `cat ./.env; false` and `source .env` are denied, while `env`, `grep -r TOKEN .` and `git commit -m ".env loading"` pass.
|
||||
- **Read gate.** A Read (or a Grep with a `path`, or a printing command that names the file) of a file on the secret list that fermata cannot mask is stopped under every `on_parse_error`. The reason names the file and the setting `[enforcement] on_unparsed_read` and says to ask the user. The files are: a file with no parser (`.netrc`, `.htpasswd`, `.p12`, `.pfx`), a key file that is a secret as a whole (`*.pem`, `*.key`, `id_rsa`, `id_ed25519`, `id_ecdsa`, unless it holds only certificates), `*.tfstate` (its secrets sit by position, not by key), and a file that cannot be parsed (a broken file, a UTF-16 or Latin-1 file, JSON with comments, text with a NUL). `on_unparsed_read = "allow"` turns the gate off.
|
||||
- **Write guard.** A Write, Edit or MultiEdit that adds a mask to a file is stopped, because the mask stands for a value fermata hid and writing it back corrupts the file. `[enforcement] on_mask_write = "allow"` turns it off.
|
||||
- **`.botignore` and relative paths.** A directory pattern such as `vendor/` matches the files below it, and a relative path is taken against the project root. The path is also checked as the file system resolves it, so a symlink does not hide what it points at.
|
||||
|
||||
Reference in New Issue
Block a user