mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 08:11:09 +00:00
fix(policy): preserve optional tool opt-ins for allow-all configs
This commit is contained in:
@@ -39,7 +39,7 @@ describe("pickSandboxToolPolicy", () => {
|
||||
alsoAllow: ["web_search"],
|
||||
}),
|
||||
).toEqual({
|
||||
allow: [],
|
||||
allow: ["*", "web_search"],
|
||||
deny: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ function unionAllow(base?: string[], extra?: string[]): string[] | undefined {
|
||||
return Array.from(new Set(["*", ...extra]));
|
||||
}
|
||||
if (base.length === 0) {
|
||||
return base;
|
||||
return Array.from(new Set(["*", ...extra]));
|
||||
}
|
||||
return Array.from(new Set([...base, ...extra]));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { SandboxToolPolicy } from "./sandbox/types.js";
|
||||
import { TOOL_POLICY_CONFORMANCE } from "./tool-policy.conformance.js";
|
||||
import {
|
||||
applyOwnerOnlyToolPolicy,
|
||||
collectExplicitAllowlist,
|
||||
expandToolGroups,
|
||||
isOwnerOnlyToolName,
|
||||
normalizeToolName,
|
||||
@@ -109,6 +110,16 @@ describe("tool-policy", () => {
|
||||
expect(applyOwnerOnlyToolPolicy(tools, true)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("preserves explicit alsoAllow hints when allow is empty", () => {
|
||||
expect(
|
||||
collectExplicitAllowlist([
|
||||
{
|
||||
allow: ["*", "optional-demo"],
|
||||
},
|
||||
]),
|
||||
).toContain("optional-demo");
|
||||
});
|
||||
|
||||
it("strips nodes for non-owner senders via fallback policy", () => {
|
||||
const tools = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user