fix(fermata): a path call's leading ~/ is expanded, so Grep with path ~/.ssh/id_rsa meets the gate

This commit is contained in:
2026-11-07 09:02:27 +01:00
parent 8998540375
commit 33e330a4eb
5 changed files with 30 additions and 17 deletions
+12
View File
@@ -221,6 +221,18 @@ fn a_command_naming_a_file_in_home_meets_the_read_gate() {
assert_eq!(call("ls ~/.ssh/id_rsa"), json!({}));
}
/// A path call's leading `~/` is the same home.
#[test]
fn a_path_call_naming_a_file_in_home_meets_the_read_gate() {
let p = project(&[]);
let home = tempfile::tempdir().unwrap();
write(home.path(), &[(".ssh/id_rsa", PEM), (".ssh/config", "Host x\n")]);
let call = |tool: &str, input: Value| hook_in(p.path(), home.path(), json!({"tool_name": tool, "tool_input": input}));
assert_eq!(verdict(&call("Grep", json!({"pattern": "x", "path": "~/.ssh/id_rsa"}))), "deny");
assert_eq!(verdict(&call("Read", json!({"file_path": "~/.ssh/id_rsa"}))), "deny");
assert_eq!(call("Grep", json!({"pattern": "x", "path": "~/.ssh/config"})), json!({}));
}
/// The session's directory resolves the words, not this process's.
#[test]
fn the_payloads_cwd_resolves_a_commands_words() {