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

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
S
SegmentFault 最新的问题
博客园 - Franky
博客园_首页
T
Tailwind CSS Blog
雷峰网
雷峰网
罗磊的独立博客

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: preflight malformed openshell exec commands · opencl...
brokemac79 · 2026-05-26 · via Recent Commits to openclaw:main

@@ -1,12 +1,19 @@

11

import fs from "node:fs/promises";

22

import os from "node:os";

33

import path from "node:path";

4-

import { createSandboxTestContext } from "openclaw/plugin-sdk/test-fixtures";

4+

import type { CreateSandboxBackendParams } from "openclaw/plugin-sdk/sandbox";

5+

import {

6+

createSandboxBrowserConfig,

7+

createSandboxPruneConfig,

8+

createSandboxSshConfig,

9+

createSandboxTestContext,

10+

} from "openclaw/plugin-sdk/test-fixtures";

511

import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

612

import type { OpenShellSandboxBackend } from "./backend.js";

713

import {

814

applyGatewayEndpointToSshConfig,

915

buildExecRemoteCommand,

16+

buildValidatedExecRemoteCommand,

1017

buildOpenShellBaseArgv,

1118

resolveOpenShellCommand,

1219

runOpenShellCli,

@@ -19,6 +26,7 @@ const cliMocks = vi.hoisted(() => ({

1926

}));

20272128

let createOpenShellSandboxBackendManager: typeof import("./backend.js").createOpenShellSandboxBackendManager;

29+

let createOpenShellSandboxBackendFactory: typeof import("./backend.js").createOpenShellSandboxBackendFactory;

22302331

describe("openshell cli helpers", () => {

2432

const originalEnv = { ...process.env };

@@ -77,6 +85,15 @@ describe("openshell cli helpers", () => {

7785

expect(command).toContain(`'cd '"'"'/sandbox/project'"'"' && pwd && printenv TOKEN'`);

7886

});

798788+

it("uses the shared SSH exec command preflight", () => {

89+

expect(() =>

90+

buildValidatedExecRemoteCommand({

91+

command: 'workflow run <workflow-id> "<task>"',

92+

env: {},

93+

}),

94+

).toThrow(/unresolved placeholder token <workflow-id>/);

95+

});

96+8097

it("passes direct gateway endpoints to openshell commands without registration", async () => {

8198

const calls: string[][] = [];

8299

const openshellCommand = await makeExecutable({

@@ -151,7 +168,8 @@ describe("openshell backend manager", () => {

151168

runOpenShellCli: cliMocks.runOpenShellCli,

152169

};

153170

});

154-

({ createOpenShellSandboxBackendManager } = await import("./backend.js"));

171+

({ createOpenShellSandboxBackendFactory, createOpenShellSandboxBackendManager } =

172+

await import("./backend.js"));

155173

});

156174157175

afterAll(() => {

@@ -261,10 +279,59 @@ describe("openshell backend manager", () => {

261279

args: ["sandbox", "delete", "openclaw-session-5678"],

262280

});

263281

});

282+283+

it("rejects malformed exec commands before opening an OpenShell SSH session", async () => {

284+

const factory = createOpenShellSandboxBackendFactory({

285+

pluginConfig: resolveOpenShellPluginConfig({

286+

command: "openshell",

287+

}),

288+

});

289+

const backend = await factory({

290+

sessionKey: "agent:main:turn",

291+

scopeKey: "agent:main",

292+

workspaceDir: "/tmp/workspace",

293+

agentWorkspaceDir: "/tmp/workspace",

294+

cfg: createOpenShellBackendSandboxConfig(),

295+

});

296+297+

await expect(

298+

backend.buildExecSpec({

299+

command: "workflow install <name>",

300+

env: {},

301+

usePty: false,

302+

}),

303+

).rejects.toThrow(/unresolved placeholder token <name>/);

304+

expect(cliMocks.runOpenShellCli).not.toHaveBeenCalled();

305+

});

264306

});

265307266308

const tempDirs: string[] = [];

267309310+

function createOpenShellBackendSandboxConfig(): CreateSandboxBackendParams["cfg"] {

311+

return {

312+

mode: "all",

313+

backend: "openshell",

314+

scope: "session",

315+

workspaceAccess: "rw",

316+

workspaceRoot: "/tmp/openclaw-sandboxes",

317+

docker: {

318+

image: "openclaw-sandbox:bookworm-slim",

319+

containerPrefix: "openclaw-sbx-",

320+

workdir: "/workspace",

321+

readOnlyRoot: false,

322+

tmpfs: [],

323+

network: "none",

324+

capDrop: [],

325+

binds: [],

326+

env: {},

327+

},

328+

ssh: createSandboxSshConfig("/tmp/openclaw-sandboxes"),

329+

browser: createSandboxBrowserConfig(),

330+

tools: { allow: ["*"], deny: [] },

331+

prune: createSandboxPruneConfig(),

332+

};

333+

}

334+268335

async function makeTempDir(prefix: string) {

269336

const dir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));

270337

tempDirs.push(dir);