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

推荐订阅源

G
Google Developers Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
博客园 - 聂微东
M
MIT News - Artificial intelligence
博客园_首页
Jina AI
Jina AI
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Vercel News
Vercel News
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
B
Blog
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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
fix: parse sandbox stat fields strictly · openclaw/opencl...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

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

1+

export function parseSandboxStatSize(value: string | undefined): number {

2+

const raw = value ?? "0";

3+

if (!/^\d+$/.test(raw)) {

4+

return 0;

5+

}

6+

const size = Number(raw);

7+

return Number.isFinite(size) ? size : 0;

8+

}

9+
10+

export function parseSandboxStatMtimeMs(value: string | undefined): number {

11+

const raw = value ?? "0";

12+

if (/^\d+(?:\.\d+)?$/.test(raw)) {

13+

const mtimeMs = Number(raw) * 1000;

14+

return Number.isFinite(mtimeMs) ? mtimeMs : 0;

15+

}

16+

const parsed = Date.parse(raw);

17+

return Number.isFinite(parsed) ? parsed : 0;

18+

}

Original file line numberDiff line numberDiff line change

@@ -216,4 +216,35 @@ describe("sandbox fs bridge anchored ops", () => {

216216

expect(args).not.toContain("/workspace/nested/file.txt");

217217

});

218218

});

219+
220+

it("does not accept partial stat size output", async () => {

221+

await withTempDir("openclaw-fs-bridge-stat-parse-", async (stateDir) => {

222+

const workspaceDir = path.join(stateDir, "workspace");

223+

await fs.mkdir(workspaceDir, { recursive: true });

224+
225+

mockedExecDockerRaw.mockImplementation(async (args) => {

226+

const script = getDockerScript(args);

227+

if (script.includes('readlink -f -- "$cursor"')) {

228+

return dockerExecResult(`${getDockerArg(args, 1)}\n`);

229+

}

230+

if (script.includes('stat -c "%F|%s|%y"')) {

231+

return dockerExecResult("regular file|12oops|not-a-date\n");

232+

}

233+

return dockerExecResult("");

234+

});

235+
236+

const bridge = createSandboxFsBridge({

237+

sandbox: createSandbox({

238+

workspaceDir,

239+

agentWorkspaceDir: workspaceDir,

240+

}),

241+

});

242+
243+

await expect(bridge.stat({ filePath: "note.txt" })).resolves.toMatchObject({

244+

type: "file",

245+

size: 0,

246+

mtimeMs: 0,

247+

});

248+

});

249+

});

219250

});

Original file line numberDiff line numberDiff line change

@@ -13,6 +13,7 @@ import {

1313

} from "./fs-bridge-mutation-helper.js";

1414

import { SandboxFsPathGuard } from "./fs-bridge-path-safety.js";

1515

import { buildStatPlan, type SandboxFsCommandPlan } from "./fs-bridge-shell-command-plans.js";

16+

import { parseSandboxStatMtimeMs, parseSandboxStatSize } from "./fs-bridge-stat-parse.js";

1617

import type { SandboxFsBridge, SandboxFsStat, SandboxResolvedPath } from "./fs-bridge.types.js";

1718

import {

1819

buildSandboxFsMounts,

@@ -36,15 +37,6 @@ export function createSandboxFsBridge(params: {

3637

return new SandboxFsBridgeImpl(params.sandbox);

3738

}

3839
39-

function parseStatMtimeMs(value: string | undefined): number {

40-

const raw = value ?? "0";

41-

if (/^\d+(?:\.\d+)?$/.test(raw)) {

42-

return Number(raw) * 1000;

43-

}

44-

const parsed = Date.parse(raw);

45-

return Number.isFinite(parsed) ? parsed : 0;

46-

}

47-
4840

class SandboxFsBridgeImpl implements SandboxFsBridge {

4941

private readonly sandbox: SandboxFsBridgeContext;

5042

private readonly mounts: ReturnType<typeof buildSandboxFsMounts>;

@@ -216,11 +208,10 @@ class SandboxFsBridgeImpl implements SandboxFsBridge {

216208

}

217209

const text = result.stdout.toString("utf8").trim();

218210

const [typeRaw, sizeRaw, mtimeRaw] = text.split("|");

219-

const size = Number.parseInt(sizeRaw ?? "0", 10);

220211

return {

221212

type: coerceStatType(typeRaw),

222-

size: Number.isFinite(size) ? size : 0,

223-

mtimeMs: parseStatMtimeMs(mtimeRaw),

213+

size: parseSandboxStatSize(sizeRaw),

214+

mtimeMs: parseSandboxStatMtimeMs(mtimeRaw),

224215

};

225216

}

226217
Original file line numberDiff line numberDiff line change

@@ -181,6 +181,57 @@ describe("remote sandbox fs bridge", () => {

181181

});

182182

},

183183

);

184+
185+

it("does not return NaN or partial values for malformed stat output", async () => {

186+

await withTempDir("openclaw-remote-fs-bridge-stat-", async (stateDir) => {

187+

const workspaceDir = path.join(stateDir, "workspace");

188+

await fs.mkdir(workspaceDir, { recursive: true });

189+

const runtime: RemoteShellSandboxHandle = {

190+

remoteWorkspaceDir: workspaceDir,

191+

remoteAgentWorkspaceDir: workspaceDir,

192+

runRemoteShellScript: async (command) => {

193+

if (command.script.includes('if [ -e "$1" ] || [ -L "$1" ]')) {

194+

return { stdout: Buffer.from("1\n"), stderr: Buffer.alloc(0), code: 0 };

195+

}

196+

if (command.script.includes('readlink -f -- "$cursor"')) {

197+

return {

198+

stdout: Buffer.from(`${workspaceDir}/note.txt\n`),

199+

stderr: Buffer.alloc(0),

200+

code: 0,

201+

};

202+

}

203+

if (command.script.includes('stat -c "%F|%h"')) {

204+

return {

205+

stdout: Buffer.from("regular file|1\n"),

206+

stderr: Buffer.alloc(0),

207+

code: 0,

208+

};

209+

}

210+

if (command.script.includes('stat -c "%F|%s|%y"')) {

211+

return {

212+

stdout: Buffer.from("regular file|12oops|not-a-date\n"),

213+

stderr: Buffer.alloc(0),

214+

code: 0,

215+

};

216+

}

217+

throw new Error(`unexpected remote script: ${command.script}`);

218+

},

219+

};

220+

const bridge = createRemoteShellSandboxFsBridge({

221+

sandbox: createSandbox({

222+

workspaceDir,

223+

agentWorkspaceDir: workspaceDir,

224+

}),

225+

runtime,

226+

});

227+
228+

await expect(bridge.stat({ filePath: "note.txt" })).resolves.toEqual({

229+

type: "file",

230+

size: 0,

231+

mtimeMs: 0,

232+

});

233+

});

234+

});

184235

});

185236
186237

async function withTempDir<T>(prefix: string, run: (stateDir: string) => Promise<T>): Promise<T> {

Original file line numberDiff line numberDiff line change

@@ -7,6 +7,7 @@ import type {

77

} from "./backend-handle.types.js";

88

import { SANDBOX_PINNED_MUTATION_PYTHON } from "./fs-bridge-mutation-helper.js";

99

import { createWritableRenameTargetResolver } from "./fs-bridge-rename-targets.js";

10+

import { parseSandboxStatMtimeMs, parseSandboxStatSize } from "./fs-bridge-stat-parse.js";

1011

import type { SandboxFsBridge, SandboxFsStat, SandboxResolvedPath } from "./fs-bridge.types.js";

1112

import {

1213

isPathInsideContainerRoot,

@@ -15,15 +16,6 @@ import {

1516

} from "./path-utils.js";

1617

import { isExistingWorkspaceSkillMountSource } from "./workspace-mounts.js";

1718
18-

function parseStatMtimeMs(value: string | undefined): number {

19-

const raw = value ?? "0";

20-

if (/^\d+(?:\.\d+)?$/.test(raw)) {

21-

return Number(raw) * 1000;

22-

}

23-

const parsed = Date.parse(raw);

24-

return Number.isFinite(parsed) ? parsed : 0;

25-

}

26-
2719

type RemoteMountSource = "workspace" | "agent" | "protectedSkill";

2820
2921

type ResolvedRemotePath = SandboxResolvedPath & {

@@ -252,8 +244,8 @@ class RemoteShellSandboxFsBridge implements SandboxFsBridge {

252244

const [kindRaw = "", sizeRaw = "0", mtimeRaw = "0"] = output.split("|");

253245

return {

254246

type: kindRaw === "directory" ? "directory" : kindRaw === "regular file" ? "file" : "other",

255-

size: Number(sizeRaw),

256-

mtimeMs: parseStatMtimeMs(mtimeRaw),

247+

size: parseSandboxStatSize(sizeRaw),

248+

mtimeMs: parseSandboxStatMtimeMs(mtimeRaw),

257249

};

258250

}

259251