fix(fermata): what a command writes meets the rules, also when it is not there yet

cp a.txt vendor/new, touch .env, echo x > .env and curl -o vendor/new are stopped under a
rule. Verb::Writes covers redirect targets, a list of writing verbs, sed -i, dd of= and
the value of -o. It meets [policy.write] as well as .botignore and [policy.read], and not
the read gate: writing a file reveals nothing.
This commit is contained in:
2026-11-07 09:00:45 +01:00
parent 8dd5a81bc8
commit bc984b8625
5 changed files with 167 additions and 45 deletions
+5 -4
View File
@@ -441,14 +441,15 @@ fn a_flag_value_as_verb_and_a_glob_over_directories_pass_the_read_gate() {
}
}
/// A file a command is about to make is not there to check, so a rule on its directory
/// does not stop it. A redirect's target is checked.
/// Writing verbs are a list. A new file named to any other program is not there to check,
/// and a flag's value is one word among others.
#[test]
fn a_new_file_a_command_names_is_not_checked_unless_a_redirect_writes_it() {
fn a_new_file_named_to_a_verb_off_the_writing_list_is_not_checked() {
let p = project(&[(".botignore", b"vendor/\n"), ("vendor/a", b"x"), ("a.txt", b"x")]);
for command in ["cp a.txt vendor/new", "touch vendor/new", "mkdir vendor/new"] {
for command in ["git clone https://example.invalid/x vendor/new", "unzip a.zip -d vendor/new", "python make.py vendor/new", "cp --target-directory=vendor/new a.txt"] {
assert!(passes(&p.bash(command)), "{command}");
}
assert!(denied(&p.bash("cp a.txt vendor/new")), "control");
assert!(denied(&p.bash("tool > vendor/new")), "control");
}