mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-28 05:13:34 +00:00
fix(policy): honor plugin group for declared mcp denies
This commit is contained in:
@@ -46,6 +46,7 @@ function denylistBlocksMcpServer(params: {
|
||||
}): boolean {
|
||||
return (
|
||||
denylistBlocksName("bundle-mcp", params.denylist) ||
|
||||
matchesAnyGlobPattern("group:plugins", params.denylist) ||
|
||||
denylistContainsMcpServerEntry({
|
||||
safeServerName: params.safeServerName,
|
||||
rawDenylist: params.rawDenylist,
|
||||
|
||||
@@ -336,6 +336,35 @@ describe("tool-policy-pipeline", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("warns when plugin group is denied and MCP server namespace is allowlisted", () => {
|
||||
const warnings: string[] = [];
|
||||
const declared = buildDeclaredToolAllowlistContext({
|
||||
config: {
|
||||
mcp: { servers: { paperless: { command: "paperless-mcp" } } },
|
||||
},
|
||||
workspaceDir: process.cwd(),
|
||||
toolDenylist: ["group:plugins"],
|
||||
});
|
||||
|
||||
applyToolPolicyPipeline({
|
||||
tools: [{ name: "exec" }] as any,
|
||||
toolMeta: () => undefined,
|
||||
warn: (msg) => warnings.push(msg),
|
||||
declaredToolAllowlist: declared,
|
||||
steps: [
|
||||
{
|
||||
policy: { allow: ["paperless__*"] },
|
||||
label: "tools.allow",
|
||||
stripPluginOnlyAllowlist: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(warnings).toEqual([
|
||||
"tools: tools.allow allowlist contains unknown entries (paperless__*). These entries won't match any tool unless the plugin is enabled.",
|
||||
]);
|
||||
});
|
||||
|
||||
test("warns when denied duplicate-safe MCP server namespace is allowlisted", () => {
|
||||
const warnings: string[] = [];
|
||||
const declared = buildDeclaredToolAllowlistContext({
|
||||
|
||||
Reference in New Issue
Block a user