mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:48:27 +00:00
fix(security): centralize owner-only tool gating and scope maps
This commit is contained in:
@@ -22,11 +22,13 @@ function createOwnerPolicyTools() {
|
||||
},
|
||||
{
|
||||
name: "cron",
|
||||
ownerOnly: true,
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
execute: async () => ({ content: [], details: {} }) as any,
|
||||
},
|
||||
{
|
||||
name: "gateway",
|
||||
ownerOnly: true,
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
execute: async () => ({ content: [], details: {} }) as any,
|
||||
},
|
||||
@@ -89,6 +91,19 @@ describe("tool-policy", () => {
|
||||
const filtered = applyOwnerOnlyToolPolicy(tools, true);
|
||||
expect(filtered.map((t) => t.name)).toEqual(["read", "cron", "gateway", "whatsapp_login"]);
|
||||
});
|
||||
|
||||
it("honors ownerOnly metadata for custom tool names", async () => {
|
||||
const tools = [
|
||||
{
|
||||
name: "custom_admin_tool",
|
||||
ownerOnly: true,
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
execute: async () => ({ content: [], details: {} }) as any,
|
||||
},
|
||||
] as unknown as AnyAgentTool[];
|
||||
expect(applyOwnerOnlyToolPolicy(tools, false)).toEqual([]);
|
||||
expect(applyOwnerOnlyToolPolicy(tools, true)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("TOOL_POLICY_CONFORMANCE", () => {
|
||||
|
||||
Reference in New Issue
Block a user