惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
小众软件
小众软件
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - 聂微东
Recent Announcements
Recent Announcements
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
云风的 BLOG
云风的 BLOG
量子位
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
博客园 - 司徒正美
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(security): share tool policy layering · openclaw...
vincentkoc · 2026-06-23 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -25,6 +25,7 @@ import type { AnyAgentTool } from "./agent-tools.types.js";

2525

import { resolveProviderToolPolicy } from "./provider-tool-policy.js";

2626

import { pickSandboxToolPolicy } from "./sandbox-tool-policy.js";

2727

import type { SandboxToolPolicy } from "./sandbox.js";

28+

import { resolveSandboxToolPolicyForAgent } from "./sandbox/tool-policy.js";

2829

import {

2930

resolveSubagentCapabilityStore,

3031

resolveStoredSubagentInheritedToolAllowlist,

@@ -144,6 +145,44 @@ export function filterToolsByPolicy(tools: AnyAgentTool[], policy?: SandboxToolP

144145

return tools.filter((tool) => isToolAllowedByPolicyName(tool.name, policy));

145146

}

146147
148+

/** Resolve the shared profile, scope, extra, and sandbox policy layers. */

149+

export function resolveConfiguredToolPolicies(params: {

150+

cfg: OpenClawConfig;

151+

agentTools?: AgentToolsConfig;

152+

sandboxMode?: "off" | "non-main" | "all";

153+

agentId?: string | null;

154+

extraPolicies?: readonly (SandboxToolPolicy | undefined)[];

155+

}): SandboxToolPolicy[] {

156+

const policies: SandboxToolPolicy[] = [];

157+

const profile = params.agentTools?.profile ?? params.cfg.tools?.profile;

158+

const profilePolicy = resolveToolProfilePolicy(profile);

159+

if (profilePolicy) {

160+

policies.push(profilePolicy);

161+

}

162+
163+

const globalPolicy = pickSandboxToolPolicy(params.cfg.tools ?? undefined);

164+

if (globalPolicy) {

165+

policies.push(globalPolicy);

166+

}

167+
168+

const agentPolicy = pickSandboxToolPolicy(params.agentTools);

169+

if (agentPolicy) {

170+

policies.push(agentPolicy);

171+

}

172+
173+

for (const policy of params.extraPolicies ?? []) {

174+

if (policy) {

175+

policies.push(policy);

176+

}

177+

}

178+
179+

if (params.sandboxMode === "all") {

180+

policies.push(resolveSandboxToolPolicyForAgent(params.cfg, params.agentId ?? undefined));

181+

}

182+
183+

return policies;

184+

}

185+
147186

function collectUniqueStrings(values: Array<string | null | undefined>): string[] {

148187

return normalizeUniqueSingleOrTrimmedStringList(values);

149188

}

Original file line numberDiff line numberDiff line change

@@ -1,18 +1,18 @@

11

// Summarizes extra security audit findings for user-facing output.

2-

import { resolveProviderToolPolicy } from "../agents/agent-tools.policy.js";

2+

import {

3+

resolveConfiguredToolPolicies,

4+

resolveProviderToolPolicy,

5+

} from "../agents/agent-tools.policy.js";

36

import { parseModelRef } from "../agents/model-selection-normalize.js";

47

import { resolveSandboxConfigForAgent } from "../agents/sandbox/config.js";

5-

import { resolveSandboxToolPolicyForAgent } from "../agents/sandbox/tool-policy.js";

68

import type { SandboxToolPolicy } from "../agents/sandbox/types.js";

79

import { isToolAllowedByPolicies } from "../agents/tool-policy-match.js";

8-

import { resolveToolProfilePolicy } from "../agents/tool-policy.js";

910

import type { OpenClawConfig } from "../config/types.openclaw.js";

1011

import type { AgentToolsConfig } from "../config/types.tools.js";

1112

import { hasConfiguredInternalHooks } from "../hooks/configured.js";

1213

import { hasConfiguredWebSearchCredential } from "../plugins/web-search-credential-presence.js";

1314

import { inferParamBFromIdOrName } from "../shared/model-param-b.js";

1415

import { collectAuditModelRefs } from "./audit-model-refs.js";

15-

import { pickSandboxToolPolicy } from "../agents/sandbox-tool-policy.js";

1616
1717

/** Lightweight audit finding shape used by summary-only audit helpers. */

1818

export type SecurityAuditFinding = {

@@ -67,46 +67,23 @@ function resolveToolPolicies(params: {

6767

modelProvider?: string;

6868

modelId?: string;

6969

}): SandboxToolPolicy[] {

70-

const policies: SandboxToolPolicy[] = [];

71-

const profile = params.agentTools?.profile ?? params.cfg.tools?.profile;

72-

const profilePolicy = resolveToolProfilePolicy(profile);

73-

if (profilePolicy) {

74-

policies.push(profilePolicy);

75-

}

76-
77-

const globalPolicy = pickSandboxToolPolicy(params.cfg.tools ?? undefined);

78-

if (globalPolicy) {

79-

policies.push(globalPolicy);

80-

}

81-
82-

const agentPolicy = pickSandboxToolPolicy(params.agentTools);

83-

if (agentPolicy) {

84-

policies.push(agentPolicy);

85-

}

86-
8770

const globalProviderPolicy = resolveProviderToolPolicy({

8871

byProvider: params.cfg.tools?.byProvider,

8972

modelProvider: params.modelProvider,

9073

modelId: params.modelId,

9174

});

92-

if (globalProviderPolicy) {

93-

policies.push(globalProviderPolicy);

94-

}

95-
9675

const agentProviderPolicy = resolveProviderToolPolicy({

9776

byProvider: params.agentTools?.byProvider,

9877

modelProvider: params.modelProvider,

9978

modelId: params.modelId,

10079

});

101-

if (agentProviderPolicy) {

102-

policies.push(agentProviderPolicy);

103-

}

104-
105-

if (params.sandboxMode === "all") {

106-

policies.push(resolveSandboxToolPolicyForAgent(params.cfg, params.agentId ?? undefined));

107-

}

108-
109-

return policies;

80+

return resolveConfiguredToolPolicies({

81+

cfg: params.cfg,

82+

agentTools: params.agentTools,

83+

sandboxMode: params.sandboxMode,

84+

agentId: params.agentId,

85+

extraPolicies: [globalProviderPolicy, agentProviderPolicy],

86+

});

11087

}

11188
11289

function hasWebSearchKey(cfg: OpenClawConfig, env: NodeJS.ProcessEnv): boolean {

Original file line numberDiff line numberDiff line change

@@ -1,10 +1,7 @@

11

// Resolves filesystem policy for exec and sandbox tool use.

2-

import { pickSandboxToolPolicy } from "../agents/sandbox-tool-policy.js";

2+

import { resolveConfiguredToolPolicies } from "../agents/agent-tools.policy.js";

33

import { resolveSandboxConfigForAgent } from "../agents/sandbox/config.js";

4-

import { resolveSandboxToolPolicyForAgent } from "../agents/sandbox/tool-policy.js";

5-

import type { SandboxToolPolicy } from "../agents/sandbox/types.js";

64

import { isToolAllowedByPolicies } from "../agents/tool-policy-match.js";

7-

import { resolveToolProfilePolicy } from "../agents/tool-policy.js";

85

import type { OpenClawConfig } from "../config/config.js";

96

import type { AgentToolsConfig, ExecToolConfig } from "../config/types.tools.js";

107

@@ -21,36 +18,6 @@ export type ExecFilesystemPolicyDriftHit = {

2118

execHost: NonNullable<ExecToolConfig["host"]>;

2219

};

2320
24-

function resolveToolPolicies(params: {

25-

cfg: OpenClawConfig;

26-

agentTools?: AgentToolsConfig;

27-

sandboxMode: "off" | "non-main" | "all";

28-

agentId?: string;

29-

}): SandboxToolPolicy[] {

30-

const policies: SandboxToolPolicy[] = [];

31-

const profile = params.agentTools?.profile ?? params.cfg.tools?.profile;

32-

const profilePolicy = resolveToolProfilePolicy(profile);

33-

if (profilePolicy) {

34-

policies.push(profilePolicy);

35-

}

36-
37-

const globalPolicy = pickSandboxToolPolicy(params.cfg.tools ?? undefined);

38-

if (globalPolicy) {

39-

policies.push(globalPolicy);

40-

}

41-
42-

const agentPolicy = pickSandboxToolPolicy(params.agentTools);

43-

if (agentPolicy) {

44-

policies.push(agentPolicy);

45-

}

46-
47-

if (params.sandboxMode === "all") {

48-

policies.push(resolveSandboxToolPolicyForAgent(params.cfg, params.agentId));

49-

}

50-
51-

return policies;

52-

}

53-
5421

function resolveExecHost(params: {

5522

globalExec?: ExecToolConfig;

5623

agentExec?: ExecToolConfig;

@@ -113,7 +80,7 @@ export function collectExecFilesystemPolicyDriftHits(

11380

continue;

11481

}

11582
116-

const policies = resolveToolPolicies({

83+

const policies = resolveConfiguredToolPolicies({

11784

cfg,

11885

agentTools: context.tools,

11986

sandboxMode: sandbox.mode,