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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
小众软件
小众软件
美团技术团队
Martin Fowler
Martin Fowler
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
J
Java Code Geeks
B
Blog
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
博客园 - Franky

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(scripts): avoid DEP0190 when spawning .cmd files on W...
nandanadilee · 2026-05-09 · via Recent Commits to openclaw:main

@@ -1,49 +1,91 @@

11

import { describe, expect, it } from "vitest";

2-

import {

3-

assertSafeWindowsShellArgs,

4-

prepareSpawnCommand,

5-

shouldUseShellForCommand,

6-

} from "../../scripts/ui.js";

2+

import { resolveSpawnCall, shouldUseCmdExeForCommand } from "../../scripts/ui.js";

7384

describe("scripts/ui windows spawn behavior", () => {

9-

it("enables shell for Windows command launchers that require cmd.exe", () => {

5+

it("wraps Windows command launchers with cmd.exe without enabling shell mode", () => {

106

expect(

11-

shouldUseShellForCommand("C:\\Users\\dev\\AppData\\Local\\pnpm\\pnpm.CMD", "win32"),

7+

shouldUseCmdExeForCommand("C:\\Users\\dev\\AppData\\Local\\pnpm\\pnpm.CMD", "win32"),

128

).toBe(true);

13-

expect(shouldUseShellForCommand("C:\\tools\\pnpm.bat", "win32")).toBe(true);

14-

});

15916-

it("does not enable shell for non-shell launchers", () => {

17-

expect(shouldUseShellForCommand("C:\\Program Files\\nodejs\\node.exe", "win32")).toBe(false);

18-

expect(shouldUseShellForCommand("/usr/local/bin/pnpm", "linux")).toBe(false);

10+

expect(

11+

resolveSpawnCall(

12+

"C:\\Program Files\\nodejs\\pnpm.cmd",

13+

["run", "build", "-t", "path with spaces"],

14+

{ PATH: "C:\\bin" },

15+

{ comSpec: "C:\\Windows\\System32\\cmd.exe", cwd: "C:\\repo\\ui", platform: "win32" },

16+

),

17+

).toEqual({

18+

command: "C:\\Windows\\System32\\cmd.exe",

19+

args: [

20+

"/d",

21+

"/s",

22+

"/c",

23+

'"C:\\Program Files\\nodejs\\pnpm.cmd" run build -t "path with spaces"',

24+

],

25+

options: {

26+

cwd: "C:\\repo\\ui",

27+

stdio: "inherit",

28+

env: { PATH: "C:\\bin" },

29+

shell: false,

30+

windowsVerbatimArguments: true,

31+

},

32+

});

1933

});

203421-

it("quotes Windows shell launcher paths before passing them to spawn", () => {

22-

expect(prepareSpawnCommand("C:\\Program Files\\nodejs\\pnpm.cmd", "win32")).toBe(

23-

'"C:\\Program Files\\nodejs\\pnpm.cmd"',

24-

);

25-

expect(prepareSpawnCommand("C:\\Program Files\\nodejs\\pnpm.exe", "win32")).toBe(

26-

"C:\\Program Files\\nodejs\\pnpm.exe",

27-

);

28-

expect(prepareSpawnCommand("/usr/local/bin/pnpm", "linux")).toBe("/usr/local/bin/pnpm");

29-

});

35+

it("does not use cmd.exe for non-command launchers", () => {

36+

expect(shouldUseCmdExeForCommand("C:\\Program Files\\nodejs\\node.exe", "win32")).toBe(false);

37+

expect(shouldUseCmdExeForCommand("C:\\tools\\pnpm.com", "win32")).toBe(false);

38+

expect(shouldUseCmdExeForCommand("/usr/local/bin/pnpm", "linux")).toBe(false);

303931-

it("allows safe forwarded args when shell mode is required on Windows", () => {

3240

expect(

33-

assertSafeWindowsShellArgs(["run", "build", "--filter", "@openclaw/ui"], "win32"),

34-

).toBeUndefined();

41+

resolveSpawnCall(

42+

"C:\\Program Files\\nodejs\\pnpm.exe",

43+

["run", "build"],

44+

{ PATH: "C:\\bin" },

45+

{ cwd: "C:\\repo\\ui", platform: "win32" },

46+

),

47+

).toEqual({

48+

command: "C:\\Program Files\\nodejs\\pnpm.exe",

49+

args: ["run", "build"],

50+

options: {

51+

cwd: "C:\\repo\\ui",

52+

stdio: "inherit",

53+

env: { PATH: "C:\\bin" },

54+

shell: false,

55+

},

56+

});

3557

});

365837-

it("rejects dangerous forwarded args when shell mode is required on Windows", () => {

38-

expect(() => assertSafeWindowsShellArgs(["run", "build", "evil&calc"], "win32")).toThrow(

39-

/unsafe windows shell argument/i,

40-

);

41-

expect(() => assertSafeWindowsShellArgs(["run", "build", "%PATH%"], "win32")).toThrow(

42-

/unsafe windows shell argument/i,

43-

);

59+

it("rejects unsafe cmd.exe arguments before launch", () => {

60+

expect(() =>

61+

resolveSpawnCall("C:\\tools\\pnpm.cmd", ["run", "build", "evil&calc"], undefined, {

62+

platform: "win32",

63+

}),

64+

).toThrow(/unsafe windows cmd\.exe argument/i);

65+

expect(() =>

66+

resolveSpawnCall("C:\\tools\\pnpm.cmd", ["run", "build", "%PATH%"], undefined, {

67+

platform: "win32",

68+

}),

69+

).toThrow(/unsafe windows cmd\.exe argument/i);

4470

});

457146-

it("does not reject args on non-windows platforms", () => {

47-

expect(assertSafeWindowsShellArgs(["contains&metacharacters"], "linux")).toBeUndefined();

72+

it("keeps non-Windows launches direct even with shell metacharacters", () => {

73+

expect(

74+

resolveSpawnCall(

75+

"/usr/local/bin/pnpm",

76+

["run", "build", "contains&metacharacters"],

77+

{ PATH: "/bin" },

78+

{ cwd: "/repo/ui", platform: "linux" },

79+

),

80+

).toEqual({

81+

command: "/usr/local/bin/pnpm",

82+

args: ["run", "build", "contains&metacharacters"],

83+

options: {

84+

cwd: "/repo/ui",

85+

stdio: "inherit",

86+

env: { PATH: "/bin" },

87+

shell: false,

88+

},

89+

});

4890

});

4991

});