fix(permissions): native path deny/ask rules apply to the file the tool opens
Edit/Read/Grep rules matched only the raw argument string, so a workspace symlink (or a quoted, `~`, `./`, `..`, or absolute spelling) reached a denied file. The policy now resolves the path exactly as the tools do (sanitize, expand `~`, display-cwd remap, join to the requesting session's cwd), follows symlinks parent-first, and re-checks deny/ask rules on the opened path and its target as absolute, `./`-relative and relative spellings. Escalation only: no allow is granted through a link. A link that cannot be followed forces a prompt that survives YOLO, auto mode and the session edit grant, with event reason `unresolved_link`. Permission requests now carry the requesting tool's cwd and display cwd so a child worktree session sharing its parent's handle is checked where it runs. Ported from upstream 1.0.14 (grok-build permission/policy.rs symlink re-check), reshaped for Kigi's lexical rule matcher. Claude-Session: https://claude.ai/code/session_01RUqV8HVGXcAETyYbZ2tPQ4
This commit is contained in:
1 parent
fb3fe89d33
commit
5f7416f3ef
8 files changed
+995
-34
No files matched your search
@@ -27,7 +27,7 @@ async fn subagent_spawn_context_inherits_parent_permission_handle() {
|
||||
kigi_workspace::permission::spawn_permission_manager(
|
||||
sid.clone(),
|
||||
gateway,
|
||||
cwd,
|
||||
cwd.clone(),
|
||||
kigi_workspace::permission::types::ClientType::Generic,
|
||||
Some(PermissionConfig::new(vec![PermissionRule {
|
||||
action: RuleAction::Deny,
|
||||
@@ -64,6 +64,8 @@ async fn subagent_spawn_context_inherits_parent_permission_handle() {
|
||||
Some("child-session".to_owned()),
|
||||
Some("general-purpose".to_owned()),
|
||||
Some("permission inheritance regression".to_owned()),
|
||||
cwd.clone(),
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert!(
|
||||
|
||||
Reference in new issue
Block a user