Przeglądaj źródła

core: fix permission evaluation to use rule-based matching instead of wildcard patterns

Dax Raad 1 miesiąc temu
rodzic
commit
9f38af44db
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      packages/opencode/src/permission/next.ts

+ 3 - 3
packages/opencode/src/permission/next.ts

@@ -232,9 +232,9 @@ export namespace PermissionNext {
     const result = new Set<string>()
     for (const tool of tools) {
       const permission = EDIT_TOOLS.includes(tool) ? "edit" : tool
-      if (evaluate(permission, "*", ruleset).action === "deny") {
-        result.add(tool)
-      }
+      const rule = ruleset.findLast((r) => Wildcard.match(permission, r.pattern))
+      if (!rule) continue
+      if (rule.pattern === "*" && rule.action === "deny") result.add(tool)
     }
     return result
   }