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

推荐订阅源

IT之家
IT之家
H
Help Net Security
GbyAI
GbyAI
博客园_首页
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
月光博客
月光博客
美团技术团队
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
博客园 - 叶小钗
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Proofpoint News Feed

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(exec): share policy layer merging · openclaw/ope...
vincentkoc · 2026-06-23 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -16,12 +16,7 @@ import type { ModelCompatConfig } from "../config/types.models.js";

1616

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

1717

import type { DiagnosticTraceContext } from "../infra/diagnostic-trace-context.js";

1818

import { resolveEventSessionRoutingPolicy } from "../infra/event-session-routing.js";

19-

import {

20-

type ExecAsk,

21-

type ExecMode,

22-

type ExecSecurity,

23-

resolveExecPolicyForMode,

24-

} from "../infra/exec-approvals.js";

19+

import { applyExecPolicyLayer } from "../infra/exec-policy.js";

2520

import { resolveMergedSafeBinProfileFixtures } from "../infra/exec-safe-bin-runtime-policy.js";

2621

import { logWarn } from "../logger.js";

2722

import { getPluginToolMeta } from "../plugins/tools.js";

@@ -339,35 +334,6 @@ function isApplyPatchAllowedForModel(params: {

339334

});

340335

}

341336
342-

type ExecPolicyLayer = {

343-

mode?: ExecMode;

344-

security?: ExecSecurity;

345-

ask?: ExecAsk;

346-

};

347-
348-

function hasLegacyExecPolicy(exec?: ExecPolicyLayer): boolean {

349-

return exec?.security !== undefined || exec?.ask !== undefined;

350-

}

351-
352-

function applyExecPolicyLayer(base: ExecPolicyLayer, layer?: ExecPolicyLayer): ExecPolicyLayer {

353-

if (!layer) {

354-

return base;

355-

}

356-

if (layer.mode) {

357-

return {

358-

mode: layer.mode,

359-

...resolveExecPolicyForMode(layer.mode),

360-

};

361-

}

362-

if (hasLegacyExecPolicy(layer)) {

363-

return {

364-

security: layer.security ?? base.security,

365-

ask: layer.ask ?? base.ask,

366-

};

367-

}

368-

return base;

369-

}

370-
371337

function resolveExecConfig(params: { cfg?: OpenClawConfig; agentId?: string }) {

372338

const cfg = params.cfg;

373339

const globalExec = cfg?.tools?.exec;

Original file line numberDiff line numberDiff line change

@@ -18,8 +18,8 @@ import {

1818

resolveExecApprovalsFromFile,

1919

resolveExecModeFromPolicy,

2020

resolveExecModePolicy,

21-

resolveExecPolicyForMode,

2221

} from "../infra/exec-approvals.js";

22+

import { applyExecPolicyLayer } from "../infra/exec-policy.js";

2323

import { resolveAgentConfig, resolveSessionAgentId } from "./agent-scope.js";

2424

import { isRequestedExecTargetAllowed, resolveExecTarget } from "./bash-tools.exec-runtime.js";

2525

import { resolveSandboxRuntimeStatus } from "./sandbox/runtime-status.js";

@@ -36,12 +36,6 @@ type ResolvedExecConfig = {

3636
3737

type ExecOverridesConfig = Omit<ResolvedExecConfig, "mode">;

3838
39-

// Legacy security/ask values remain accepted on existing sessions/config, but

40-

// mode wins when present because it expands to a complete policy tuple.

41-

function hasLegacyExecPolicyOverride(exec?: ResolvedExecConfig): boolean {

42-

return exec?.security !== undefined || exec?.ask !== undefined;

43-

}

44-
4539

// Layering keeps the most specific mode/security/ask while preserving policy

4640

// bounds from approvals and sandbox availability later in resolution.

4741

type LayeredExecPolicy = {

@@ -50,28 +44,6 @@ type LayeredExecPolicy = {

5044

ask: ExecAsk;

5145

};

5246
53-

function applyExecPolicyLayer(

54-

base: LayeredExecPolicy,

55-

layer?: ResolvedExecConfig,

56-

): LayeredExecPolicy {

57-

if (!layer) {

58-

return base;

59-

}

60-

if (layer.mode) {

61-

return {

62-

mode: layer.mode,

63-

...resolveExecPolicyForMode(layer.mode),

64-

};

65-

}

66-

if (hasLegacyExecPolicyOverride(layer)) {

67-

return {

68-

security: layer.security ?? base.security,

69-

ask: layer.ask ?? base.ask,

70-

};

71-

}

72-

return base;

73-

}

74-
7547

function applySessionLegacyExecPolicyLayer(

7648

base: LayeredExecPolicy,

7749

sessionEntry?: SessionEntry,

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,31 @@

1+

import type { ExecAsk, ExecMode, ExecSecurity } from "./exec-approvals.js";

2+

import { resolveExecPolicyForMode } from "./exec-approvals.js";

3+
4+

export type ExecPolicyLayer = {

5+

mode?: ExecMode;

6+

security?: ExecSecurity;

7+

ask?: ExecAsk;

8+

};

9+
10+

// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Preserve each caller's required policy fields.

11+

export function applyExecPolicyLayer<TBase extends ExecPolicyLayer>(

12+

base: TBase,

13+

layer?: ExecPolicyLayer,

14+

): TBase & ExecPolicyLayer {

15+

if (!layer) {

16+

return base;

17+

}

18+

if (layer.mode) {

19+

return {

20+

mode: layer.mode,

21+

...resolveExecPolicyForMode(layer.mode),

22+

} as TBase & ExecPolicyLayer;

23+

}

24+

if (layer.security !== undefined || layer.ask !== undefined) {

25+

return {

26+

security: layer.security ?? base.security,

27+

ask: layer.ask ?? base.ask,

28+

} as TBase & ExecPolicyLayer;

29+

}

30+

return base;

31+

}

Original file line numberDiff line numberDiff line change

@@ -19,18 +19,17 @@ import {

1919

resolveAllowAlwaysPersistenceDecision,

2020

resolveExecApprovals,

2121

resolveExecModePolicy,

22-

resolveExecPolicyForMode,

2322

type ExecAllowlistEntry,

2423

type ExecAsk,

2524

type ExecCommandSegment,

26-

type ExecMode,

2725

type ExecSegmentSatisfiedBy,

2826

type ExecSecurity,

2927

type SkillBinTrustEntry,

3028

} from "../infra/exec-approvals.js";

3129

import type { ExecAuthorizationPlan } from "../infra/exec-authorization-plan.js";

3230

import type { ExecAutoReviewer } from "../infra/exec-auto-review.js";

3331

import type { ExecHostRequest, ExecHostResponse, ExecHostRunResult } from "../infra/exec-host.js";

32+

import { applyExecPolicyLayer } from "../infra/exec-policy.js";

3433

import { resolveExecSafeBinRuntimePolicy } from "../infra/exec-safe-bin-runtime-policy.js";

3534

import {

3635

extractEnvAssignmentKeysFromDispatchWrappers,

@@ -145,12 +144,6 @@ const APPROVAL_SCRIPT_OPERAND_DRIFT_DENIED_MESSAGE =

145144

"SYSTEM_RUN_DENIED: approval script operand changed before execution";

146145

type ExecToolConfig = NonNullable<NonNullable<OpenClawConfig["tools"]>["exec"]>;

147146
148-

type LayeredExecPolicy = {

149-

mode?: ExecMode;

150-

security: ExecSecurity;

151-

ask: ExecAsk;

152-

};

153-
154147

type EffectiveSystemRunExecPolicy = {

155148

agentExec: ExecToolConfig | undefined;

156149

globalExec: ExecToolConfig | undefined;

@@ -160,29 +153,6 @@ type EffectiveSystemRunExecPolicy = {

160153

autoReview: boolean;

161154

};

162155
163-

function hasLegacyExecPolicyOverride(exec?: ExecToolConfig): boolean {

164-

return exec?.security !== undefined || exec?.ask !== undefined;

165-

}

166-
167-

function applyExecPolicyLayer(base: LayeredExecPolicy, layer?: ExecToolConfig): LayeredExecPolicy {

168-

if (!layer) {

169-

return base;

170-

}

171-

if (layer.mode) {

172-

return {

173-

mode: layer.mode,

174-

...resolveExecPolicyForMode(layer.mode),

175-

};

176-

}

177-

if (hasLegacyExecPolicyOverride(layer)) {

178-

return {

179-

security: layer.security ?? base.security,

180-

ask: layer.ask ?? base.ask,

181-

};

182-

}

183-

return base;

184-

}

185-
186156

function warnWritableTrustedDirOnce(message: string): void {

187157

if (safeBinTrustedDirWarningCache.has(message)) {

188158

return;