docs(fermata): the page drops bash -c -o pipefail and names an indented private block and the = and : write forms
This commit is contained in:
+29
-3
@@ -425,8 +425,7 @@ fn a_command_line_the_check_does_not_read_as_one_passes() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper's flag whose value is a word makes that word the verb, `-o`'s value before a
|
||||
/// shell's line is taken for its first word, `<&` ends the segment, a glob over directories
|
||||
/// A wrapper's flag whose value is a word makes that word the verb, `<&` ends the segment, a glob over directories
|
||||
/// is no file, and a wrapper by a relative path is a script: the read gate sees none of
|
||||
/// them. A rule on the file's name still reads each.
|
||||
#[test]
|
||||
@@ -435,7 +434,7 @@ fn a_flag_value_as_verb_and_a_glob_over_directories_pass_the_read_gate() {
|
||||
let p = project(&files);
|
||||
assert!(denied(&p.bash("sudo cat id_rsa")), "control");
|
||||
assert!(denied(&p.bash("cat sub/id_rsa")), "control");
|
||||
let commands = ["sudo -u root cat id_rsa", "bash -c -o pipefail 'cat id_rsa'", "cat <&3 id_rsa", "cat */id_rsa", "cat ./s*/a.key", "./env cat id_rsa", "bin/sudo cat id_rsa", "./busybox cat id_rsa"];
|
||||
let commands = ["sudo -u root cat id_rsa", "cat <&3 id_rsa", "cat */id_rsa", "cat ./s*/a.key", "./env cat id_rsa", "bin/sudo cat id_rsa", "./busybox cat id_rsa"];
|
||||
for command in commands {
|
||||
assert!(passes(&p.bash(command)), "{command}");
|
||||
}
|
||||
@@ -485,6 +484,33 @@ fn a_run_outside_any_project_is_not_masked() {
|
||||
assert!(p.after_bash(VALUE).contains(VALUE));
|
||||
}
|
||||
|
||||
/// An output flag's value given with `=` or `:`, and BSD's `sed -I`, are not read as writes.
|
||||
#[test]
|
||||
fn a_write_given_by_an_equals_sign_a_colon_or_sed_capital_i_is_not_checked() {
|
||||
let p = project(&[(".botignore", b"vendor/\n"), ("vendor/a", b"x"), ("a.txt", b"x")]);
|
||||
for command in ["tool -o=vendor/new", "sort -o=vendor/new a.txt"] {
|
||||
assert!(passes(&p.bash(command)), "{command}");
|
||||
}
|
||||
assert!(passes(&p.pre("PowerShell", json!({"command": "Copy-Item a.txt -Destination:vendor\\new"}))));
|
||||
assert!(denied(&p.bash("tool -o vendor/new")), "control");
|
||||
let p = project(&[(".botsecrets", b"[policy.write]\npatterns = [\"a.txt\"]\n"), ("a.txt", b"x")]);
|
||||
assert!(passes(&p.bash("sed -I '' s/a/b/ a.txt")));
|
||||
assert!(denied(&p.bash("sed -i s/a/b/ a.txt")), "control");
|
||||
}
|
||||
|
||||
/// A private block indented beside a certificate is read as the certificate file's text, so a
|
||||
/// Read passes. Its body is still a known value, and is masked in what the Read shows.
|
||||
#[test]
|
||||
fn an_indented_private_block_beside_a_certificate_passes_a_read() {
|
||||
const CERT: &str = "-----BEGIN CERTIFICATE-----\nFAKEFAKEfakeFAKEfake\n-----END CERTIFICATE-----\n";
|
||||
let content = format!("{CERT} -----BEGIN PRIVATE KEY-----\n fakeIndentedPrivateBody123\n -----END PRIVATE KEY-----\n");
|
||||
let p = project(&[("server.pem", content.as_bytes())]);
|
||||
assert!(passes(&p.read("server.pem")));
|
||||
assert!(is_masked(&p.after_read("server.pem", &content), "fakeIndentedPrivateBody123"));
|
||||
let p = project(&[("server.pem", format!("{CERT}-----BEGIN PRIVATE KEY-----\nfakeIndentedPrivateBody123\n-----END PRIVATE KEY-----\n").as_bytes())]);
|
||||
assert!(denied(&p.read("server.pem")), "control");
|
||||
}
|
||||
|
||||
/// The over-denials that stay. Each errs towards stopping a command.
|
||||
#[test]
|
||||
fn a_harmless_command_a_rule_still_stops() {
|
||||
|
||||
Reference in New Issue
Block a user