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

推荐订阅源

Recent Announcements
Recent Announcements
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
博客园_首页
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
Jina AI
Jina AI
月光博客
月光博客
小众软件
小众软件
S
SegmentFault 最新的问题
量子位
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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
test: move pure hotspots to fast lane · openclaw/openclaw...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,143 @@

1+

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

2+

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

3+

import { isRecord } from "../utils.js";

4+

import { collectCoreInsecureOrDangerousFlags } from "./core-dangerous-config-flags.js";

5+6+

type DangerousFlagValue = string | number | boolean | null;

7+8+

type DangerousFlagContract = {

9+

path: string;

10+

equals: DangerousFlagValue;

11+

};

12+13+

type PluginConfigContractMetadata = {

14+

configContracts: {

15+

dangerousFlags?: DangerousFlagContract[];

16+

};

17+

};

18+19+

type PluginConfigContractMatch = {

20+

path: string;

21+

value: unknown;

22+

};

23+24+

type CollectPluginConfigContractMatches = (input: {

25+

pathPattern: string;

26+

root: Record<string, unknown>;

27+

}) => Iterable<PluginConfigContractMatch>;

28+29+

export type DangerousConfigFlagContractInputs = {

30+

configContractsById?: ReadonlyMap<string, PluginConfigContractMetadata>;

31+

collectPluginConfigContractMatches?: CollectPluginConfigContractMatches;

32+

};

33+34+

function formatDangerousConfigFlagValue(value: DangerousFlagValue): string {

35+

return value === null ? "null" : String(value);

36+

}

37+38+

function getAgentDangerousFlagPathSegment(agent: unknown, index: number): string {

39+

const id =

40+

agent &&

41+

typeof agent === "object" &&

42+

!Array.isArray(agent) &&

43+

typeof (agent as { id?: unknown }).id === "string" &&

44+

(agent as { id: string }).id.length > 0

45+

? (agent as { id: string }).id

46+

: undefined;

47+

return id ? `agents.list[id=${JSON.stringify(id)}]` : `agents.list[${index}]`;

48+

}

49+50+

function collectExactPluginConfigContractMatches({

51+

pathPattern,

52+

root,

53+

}: {

54+

pathPattern: string;

55+

root: Record<string, unknown>;

56+

}): PluginConfigContractMatch[] {

57+

return Object.hasOwn(root, pathPattern) ? [{ path: pathPattern, value: root[pathPattern] }] : [];

58+

}

59+60+

export function collectEnabledInsecureOrDangerousFlagsFromContracts(

61+

cfg: OpenClawConfig,

62+

inputs: DangerousConfigFlagContractInputs = {},

63+

): string[] {

64+

const enabledFlags = collectCoreInsecureOrDangerousFlags(cfg);

65+66+

const collectSandboxDockerDangerousFlags = (

67+

docker: Record<string, unknown> | undefined,

68+

pathPrefix: string,

69+

): void => {

70+

if (!isRecord(docker)) {

71+

return;

72+

}

73+

for (const key of DANGEROUS_SANDBOX_DOCKER_BOOLEAN_KEYS) {

74+

if (docker[key] === true) {

75+

enabledFlags.push(`${pathPrefix}.${key}=true`);

76+

}

77+

}

78+

};

79+80+

if (cfg.hooks?.allowRequestSessionKey === true) {

81+

enabledFlags.push("hooks.allowRequestSessionKey=true");

82+

}

83+

if (cfg.browser?.ssrfPolicy?.dangerouslyAllowPrivateNetwork === true) {

84+

enabledFlags.push("browser.ssrfPolicy.dangerouslyAllowPrivateNetwork=true");

85+

}

86+

if (cfg.tools?.fs?.workspaceOnly === false) {

87+

enabledFlags.push("tools.fs.workspaceOnly=false");

88+

}

89+

collectSandboxDockerDangerousFlags(

90+

isRecord(cfg.agents?.defaults?.sandbox?.docker)

91+

? cfg.agents?.defaults?.sandbox?.docker

92+

: undefined,

93+

"agents.defaults.sandbox.docker",

94+

);

95+

if (Array.isArray(cfg.agents?.list)) {

96+

for (const [index, agent] of cfg.agents.list.entries()) {

97+

collectSandboxDockerDangerousFlags(

98+

isRecord(agent?.sandbox?.docker) ? agent.sandbox.docker : undefined,

99+

`${getAgentDangerousFlagPathSegment(agent, index)}.sandbox.docker`,

100+

);

101+

}

102+

}

103+104+

const pluginEntries = cfg.plugins?.entries;

105+

if (!isRecord(pluginEntries)) {

106+

return enabledFlags;

107+

}

108+109+

const configContracts = inputs.configContractsById ?? new Map();

110+

const collectPluginConfigContractMatches =

111+

inputs.collectPluginConfigContractMatches ?? collectExactPluginConfigContractMatches;

112+

const seenFlags = new Set<string>();

113+

for (const [pluginId, metadata] of configContracts.entries()) {

114+

const dangerousFlags = metadata.configContracts.dangerousFlags;

115+

if (!dangerousFlags?.length) {

116+

continue;

117+

}

118+

const pluginEntry = pluginEntries[pluginId];

119+

if (!isRecord(pluginEntry) || !isRecord(pluginEntry.config)) {

120+

continue;

121+

}

122+

for (const flag of dangerousFlags) {

123+

for (const match of collectPluginConfigContractMatches({

124+

root: pluginEntry.config,

125+

pathPattern: flag.path,

126+

})) {

127+

if (!Object.is(match.value, flag.equals)) {

128+

continue;

129+

}

130+

const rendered =

131+

`plugins.entries.${pluginId}.config.${match.path}` +

132+

`=${formatDangerousConfigFlagValue(flag.equals)}`;

133+

if (seenFlags.has(rendered)) {

134+

continue;

135+

}

136+

seenFlags.add(rendered);

137+

enabledFlags.push(rendered);

138+

}

139+

}

140+

}

141+142+

return enabledFlags;

143+

}