fix(fermata): a flag's value and an excluded name stop no harmless command
grep -A 2 .env a.txt, rg -t py .env, tar --exclude=.env and git --no-pager status .env pass under a rule on .env. A small list of grep's and rg's flags with a value, four exclude flags and git's quiet flags; grep -A 2 TOKEN .env and --include=.env stay stopped.
This commit is contained in:
@@ -456,3 +456,48 @@ fn a_command_line_given_to_any_shell_is_read() {
|
||||
assert_eq!(bash(p.path(), command), json!({}), "{command}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A flag's value is no pattern, what a command leaves out is no file it reads, and a quiet
|
||||
/// flag before `git`'s command keeps its class.
|
||||
#[test]
|
||||
fn a_flags_value_and_an_excluded_name_stop_nothing() {
|
||||
for rule in RULES {
|
||||
let p = project(&[rule, (".env", ENV), ("a.txt", "x"), ("sub/a.txt", "x")]);
|
||||
for command in [
|
||||
"grep -A 2 .env a.txt",
|
||||
"grep -m 1 .env a.txt",
|
||||
"grep -nA 2 .env a.txt",
|
||||
"grep --context 2 .env a.txt",
|
||||
"rg -n -C 2 .env a.txt",
|
||||
"rg -t py .env",
|
||||
"rg --type py .env",
|
||||
"grep -r TOKEN --exclude=.env .",
|
||||
"grep -r TOKEN --exclude .env .",
|
||||
"tar --exclude=.env -cf x.tar .",
|
||||
"tar --exclude .env -cf x.tar .",
|
||||
"rsync --exclude=.env a b",
|
||||
"npm test -- --grep=.env",
|
||||
"git --no-pager status .env",
|
||||
"git -P status .env",
|
||||
"git -C sub status ../.env",
|
||||
] {
|
||||
assert_eq!(bash(p.path(), command), json!({}), "{rule:?}: {command}");
|
||||
}
|
||||
for command in [
|
||||
// A value's flag does not hide the file after the pattern.
|
||||
"grep -A 2 TOKEN .env",
|
||||
"grep -m 1 TOKEN a.txt .env",
|
||||
"rg -t py TOKEN .env",
|
||||
// `-r` takes a value in rg and none in grep.
|
||||
"grep -r TOKEN .env",
|
||||
// These reach the file.
|
||||
"grep -r TOKEN --include=.env .",
|
||||
"tar --exclude-from=.env -cf x.tar .",
|
||||
"git --no-pager add .env",
|
||||
// `-c` can run anything, so `git -c` keeps no class.
|
||||
"git -c core.pager=x status .env",
|
||||
] {
|
||||
assert_eq!(verdict(&bash(p.path(), command)), "deny", "{rule:?}: {command}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user