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

推荐订阅源

Vercel News
Vercel News
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
G
Google Developers Blog
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
J
Java Code Geeks
U
Unit 42
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
Docker
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
V
V2EX
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(plugins): trust managed npm peer links · openclaw/ope...
vincentkoc · 2026-05-03 · via Recent Commits to openclaw:main

@@ -61,6 +61,7 @@ function writeInstalledNpmPlugin(params: {

6161

indexJs?: string;

6262

dependency?: { name: string; version: string };

6363

hoistedDependency?: { name: string; version: string };

64+

peerDependencies?: Record<string, string>;

6465

}) {

6566

const pluginDir = path.join(params.npmRoot, "node_modules", params.packageName);

6667

fs.mkdirSync(path.join(pluginDir, "dist"), { recursive: true });

@@ -73,6 +74,7 @@ function writeInstalledNpmPlugin(params: {

7374

...(params.dependency

7475

? { dependencies: { [params.dependency.name]: params.dependency.version } }

7576

: {}),

77+

...(params.peerDependencies ? { peerDependencies: params.peerDependencies } : {}),

7678

}),

7779

"utf-8",

7880

);

@@ -128,26 +130,60 @@ function mockNpmViewAndInstall(params: {

128130

indexJs?: string;

129131

dependency?: { name: string; version: string };

130132

hoistedDependency?: { name: string; version: string };

133+

peerDependencies?: Record<string, string>;

131134

}) {

135+

mockNpmViewAndInstallMany([params]);

136+

}

137+138+

function mockNpmViewAndInstallMany(

139+

packages: Array<{

140+

spec: string;

141+

packageName: string;

142+

version: string;

143+

npmRoot: string;

144+

pluginId?: string;

145+

integrity?: string;

146+

shasum?: string;

147+

indexJs?: string;

148+

dependency?: { name: string; version: string };

149+

hoistedDependency?: { name: string; version: string };

150+

peerDependencies?: Record<string, string>;

151+

}>,

152+

) {

153+

const packagesBySpec = new Map(packages.map((pkg) => [pkg.spec, pkg]));

154+

const packagesByName = new Map(packages.map((pkg) => [pkg.packageName, pkg]));

132155

runCommandWithTimeoutMock.mockImplementation(async (argv: string[]) => {

133-

if (JSON.stringify(argv) === JSON.stringify(npmViewArgv(params.spec))) {

156+

const viewPackage = packages.find(

157+

(pkg) => JSON.stringify(argv) === JSON.stringify(npmViewArgv(pkg.spec)),

158+

);

159+

if (viewPackage) {

134160

return successfulSpawn(

135161

JSON.stringify({

136-

name: params.packageName,

137-

version: params.version,

162+

name: viewPackage.packageName,

163+

version: viewPackage.version,

138164

dist: {

139-

integrity: params.integrity ?? "sha512-plugin-test",

140-

shasum: params.shasum ?? "pluginshasum",

165+

integrity: viewPackage.integrity ?? "sha512-plugin-test",

166+

shasum: viewPackage.shasum ?? "pluginshasum",

141167

},

142168

}),

143169

);

144170

}

145171

if (argv[0] === "npm" && argv[1] === "install") {

146-

writeInstalledNpmPlugin(params);

172+

const spec = argv.at(-1);

173+

const pkg = spec ? packagesBySpec.get(spec) : undefined;

174+

if (!pkg) {

175+

throw new Error(`unexpected npm install spec: ${spec ?? ""}`);

176+

}

177+

writeInstalledNpmPlugin(pkg);

147178

return successfulSpawn();

148179

}

149180

if (argv[0] === "npm" && argv[1] === "uninstall") {

150-

fs.rmSync(path.join(params.npmRoot, "node_modules", params.packageName), {

181+

const packageName = argv.at(-1);

182+

const pkg = packageName ? packagesByName.get(packageName) : undefined;

183+

if (!pkg) {

184+

throw new Error(`unexpected npm uninstall package: ${packageName ?? ""}`);

185+

}

186+

fs.rmSync(path.join(pkg.npmRoot, "node_modules", pkg.packageName), {

151187

recursive: true,

152188

force: true,

153189

});

@@ -230,6 +266,55 @@ describe("installPluginFromNpmSpec", () => {

230266

}

231267

});

232268269+

it.runIf(process.platform !== "win32")(

270+

"does not let managed openclaw peer links poison later npm installs",

271+

async () => {

272+

const stateDir = suiteTempRootTracker.makeTempDir();

273+

const npmRoot = path.join(stateDir, "npm");

274+275+

mockNpmViewAndInstallMany([

276+

{

277+

spec: "peer-plugin@1.0.0",

278+

packageName: "peer-plugin",

279+

version: "1.0.0",

280+

pluginId: "peer-plugin",

281+

npmRoot,

282+

peerDependencies: { openclaw: "^2026.0.0" },

283+

},

284+

{

285+

spec: "next-plugin@1.0.0",

286+

packageName: "next-plugin",

287+

version: "1.0.0",

288+

pluginId: "next-plugin",

289+

npmRoot,

290+

},

291+

]);

292+293+

const first = await installPluginFromNpmSpec({

294+

spec: "peer-plugin@1.0.0",

295+

npmDir: npmRoot,

296+

logger: { info: () => {}, warn: () => {} },

297+

});

298+

expect(first.ok).toBe(true);

299+

expect(

300+

fs

301+

.lstatSync(path.join(npmRoot, "node_modules", "peer-plugin", "node_modules", "openclaw"))

302+

.isSymbolicLink(),

303+

).toBe(true);

304+305+

const second = await installPluginFromNpmSpec({

306+

spec: "next-plugin@1.0.0",

307+

npmDir: npmRoot,

308+

logger: { info: () => {}, warn: () => {} },

309+

});

310+311+

expect(second.ok).toBe(true);

312+

if (!second.ok) {

313+

expect(second.error).not.toContain("peer-plugin/node_modules/openclaw");

314+

}

315+

},

316+

);

317+233318

it("allows npm-spec installs with dangerous code patterns when forced unsafe install is set", async () => {

234319

const npmRoot = path.join(suiteTempRootTracker.makeTempDir(), "npm");

235320

const warnings: string[] = [];