mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:51:26 +00:00
fix: preserve sandbox allow-all semantics
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { SandboxToolPolicy } from "./types.js";
|
||||
import { isToolAllowed } from "./tool-policy.js";
|
||||
|
||||
describe("sandbox tool policy", () => {
|
||||
it("allows all tools with * allow", () => {
|
||||
const policy: SandboxToolPolicy = { allow: ["*"], deny: [] };
|
||||
expect(isToolAllowed(policy, "browser")).toBe(true);
|
||||
});
|
||||
|
||||
it("denies all tools with * deny", () => {
|
||||
const policy: SandboxToolPolicy = { allow: [], deny: ["*"] };
|
||||
expect(isToolAllowed(policy, "read")).toBe(false);
|
||||
});
|
||||
|
||||
it("supports wildcard patterns", () => {
|
||||
const policy: SandboxToolPolicy = { allow: ["web_*"] };
|
||||
expect(isToolAllowed(policy, "web_fetch")).toBe(true);
|
||||
expect(isToolAllowed(policy, "read")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -89,6 +89,9 @@ export function resolveSandboxToolPolicyForAgent(
|
||||
// `image` is essential for multimodal workflows; always include it in sandboxed
|
||||
// sessions unless explicitly denied.
|
||||
if (
|
||||
// Empty allowlist means "allow all" for `isToolAllowed`, so don't inject a
|
||||
// single tool that would accidentally turn it into an explicit allowlist.
|
||||
expandedAllow.length > 0 &&
|
||||
!expandedDeny.map((v) => v.toLowerCase()).includes("image") &&
|
||||
!expandedAllow.map((v) => v.toLowerCase()).includes("image")
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user