























@@ -13,6 +13,24 @@ vi.mock("./tools/gateway.js", () => ({
1313readGatewayCallOptions: vi.fn(() => ({})),
1414}));
151516+function installAllowlistedGogFixture(root: string): string {
17+const binDir = path.join(root, "bin");
18+const openclawDir = path.join(root, ".openclaw");
19+fs.mkdirSync(binDir, { recursive: true });
20+fs.mkdirSync(openclawDir, { recursive: true });
21+const gogPath = path.join(binDir, "gog");
22+fs.writeFileSync(gogPath, "#!/bin/sh\nprintf 'gog-ok %s\\n' \"$*\"\n", { mode: 0o755 });
23+fs.writeFileSync(
24+path.join(openclawDir, "exec-approvals.json"),
25+`${JSON.stringify({
26+ version: 1,
27+ defaults: { security: "allowlist", ask: "off", askFallback: "allowlist" },
28+ agents: { "*": { allowlist: [{ pattern: gogPath }] } },
29+ })}\n`,
30+);
31+return binDir;
32+}
33+1634describe("exec security floor", () => {
1735let envSnapshot: ReturnType<typeof captureEnv>;
1836let tempRoot: string | undefined;
@@ -88,6 +106,52 @@ describe("exec security floor", () => {
88106).rejects.toThrow(/exec denied: allowlist miss/i);
89107});
90108109+it("ignores model-supplied ask overrides when configured ask is off", async () => {
110+const root = tempRoot ?? os.tmpdir();
111+const binDir = installAllowlistedGogFixture(root);
112+const tool = createExecTool({
113+host: "gateway",
114+security: "allowlist",
115+ask: "off",
116+safeBins: [],
117+pathPrepend: [binDir],
118+messageProvider: "telegram",
119+currentChannelId: "telegram:12345",
120+accountId: "default",
121+});
122+123+const result = await tool.execute("call-model-ask-ignored", {
124+command: "gog tasks add tasklist --title test",
125+ask: "always",
126+});
127+128+expect(result.details.status).toBe("completed");
129+expect((result.content[0] as { text?: string }).text ?? "").toContain(
130+"gog-ok tasks add tasklist --title test",
131+);
132+expect(callGatewayTool).not.toHaveBeenCalled();
133+});
134+135+it("honors per-call ask hardening for trusted callers without messageProvider", async () => {
136+const root = tempRoot ?? os.tmpdir();
137+const binDir = installAllowlistedGogFixture(root);
138+const tool = createExecTool({
139+host: "gateway",
140+security: "allowlist",
141+ask: "off",
142+safeBins: [],
143+pathPrepend: [binDir],
144+});
145+146+const result = await tool.execute("call-trusted-ask-always", {
147+command: "gog tasks add tasklist --title test",
148+ask: "always",
149+});
150+151+expect(callGatewayTool).toHaveBeenCalled();
152+expect(result.details.status).toBe("approval-pending");
153+});
154+91155it("ignores model-supplied deny security when configured security is allowlist", async () => {
92156const tool = createExecTool({
93157security: "allowlist",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。