fix(tool-policy): deny write no longer silently hides apply_patch (#7… · openclaw/openclaw@8da9d8c
hclsys
·
2026-05-04
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import type { OpenClawConfig } from "../config/config.js";
|
3 | 3 | import { DEFAULT_GATEWAY_HTTP_TOOL_DENY } from "../security/dangerous-tools.js"; |
4 | 4 | import { isToolAllowed, resolveSandboxToolPolicyForAgent } from "./sandbox/tool-policy.js"; |
5 | 5 | import type { SandboxToolPolicy } from "./sandbox/types.js"; |
| 6 | +import { isToolAllowedByPolicyName } from "./tool-policy-match.js"; |
6 | 7 | import { TOOL_POLICY_CONFORMANCE } from "./tool-policy.conformance.js"; |
7 | 8 | import { |
8 | 9 | applyOwnerOnlyToolPolicy, |
@@ -264,3 +265,23 @@ describe("resolveSandboxToolPolicyForAgent", () => {
|
264 | 265 | expect(resolved.deny).toEqual(["image"]); |
265 | 266 | }); |
266 | 267 | }); |
| 268 | + |
| 269 | +describe("isToolAllowedByPolicyName — apply_patch / write deny decoupling (#76749)", () => { |
| 270 | +it("does not deny apply_patch when write is denied", () => { |
| 271 | +expect(isToolAllowedByPolicyName("apply_patch", { deny: ["write"] })).toBe(true); |
| 272 | +}); |
| 273 | + |
| 274 | +it("still denies apply_patch when apply_patch is explicitly denied", () => { |
| 275 | +expect(isToolAllowedByPolicyName("apply_patch", { deny: ["apply_patch"] })).toBe(false); |
| 276 | +}); |
| 277 | + |
| 278 | +it("still allows apply_patch via write in the allow list", () => { |
| 279 | +expect(isToolAllowedByPolicyName("apply_patch", { allow: ["write"], deny: [] })).toBe(true); |
| 280 | +}); |
| 281 | + |
| 282 | +it("denies apply_patch when both write and apply_patch are denied", () => { |
| 283 | +expect(isToolAllowedByPolicyName("apply_patch", { deny: ["write", "apply_patch"] })).toBe( |
| 284 | +false, |
| 285 | +); |
| 286 | +}); |
| 287 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。