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

推荐订阅源

云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
博客园 - Franky
J
Java Code Geeks
V
Visual Studio Blog
G
Google Developers Blog
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
博客园 - 【当耐特】
IT之家
IT之家
I
InfoQ
U
Unit 42
C
Check Point Blog
Martin Fowler
Martin Fowler

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(test): avoid scanning publishable plugin packages · o...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,9 +1,9 @@

1-

import { execFile } from "node:child_process";

2-

import { copyFileSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";

1+

import { execFile, spawnSync } from "node:child_process";

2+

import fs, { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";

33

import { tmpdir } from "node:os";

44

import { dirname, join, relative, resolve, sep } from "node:path";

55

import { promisify } from "node:util";

6-

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

6+

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

77

import { isScannable, scanDirectoryWithSummary } from "../security/skill-scanner.js";

8899

type NpmPackFile = {

@@ -130,11 +130,73 @@ function stageScannerRelevantPackedFiles(

130130

return stageDir;

131131

}

132132133-

function collectPublishablePluginPackages(): PublishablePluginPackage[] {

134-

return readdirSync("extensions", { withFileTypes: true })

133+

function listPublishablePluginPackageDirs(): string[] {

134+

const externalDirs = listExternalPluginPackageDirs();

135+

if (externalDirs) {

136+

return externalDirs;

137+

}

138+

return fs

139+

.readdirSync("extensions", { withFileTypes: true })

135140

.filter((entry) => entry.isDirectory())

136-

.flatMap((entry) => {

137-

const packageDir = join("extensions", entry.name);

141+

.map((entry) => join("extensions", entry.name))

142+

.toSorted();

143+

}

144+145+

function listExternalPluginPackageDirs(): string[] | null {

146+

const packageFiles = listGitExtensionPackageFiles() ?? listFindExtensionPackageFiles();

147+

if (!packageFiles) {

148+

return null;

149+

}

150+

return packageFiles

151+

.flatMap((file) => {

152+

const match = /^extensions\/([^/]+)\/package\.json$/u.exec(file);

153+

return match?.[1] ? [join("extensions", match[1])] : [];

154+

})

155+

.toSorted();

156+

}

157+158+

function listGitExtensionPackageFiles(): string[] | null {

159+

const result = spawnSync("git", ["ls-files", "--", "extensions/*/package.json"], {

160+

cwd: process.cwd(),

161+

encoding: "utf8",

162+

maxBuffer: 1024 * 1024,

163+

stdio: ["ignore", "pipe", "ignore"],

164+

});

165+

if (result.status !== 0) {

166+

return null;

167+

}

168+

return result.stdout

169+

.split("\n")

170+

.map((line) => line.trim())

171+

.filter((line) => line.length > 0)

172+

.toSorted();

173+

}

174+175+

function listFindExtensionPackageFiles(): string[] | null {

176+

const result = spawnSync(

177+

"find",

178+

[resolve("extensions"), "-maxdepth", "2", "-type", "f", "-name", "package.json"],

179+

{

180+

cwd: process.cwd(),

181+

encoding: "utf8",

182+

maxBuffer: 1024 * 1024,

183+

stdio: ["ignore", "pipe", "ignore"],

184+

},

185+

);

186+

if (result.status !== 0) {

187+

return null;

188+

}

189+

return result.stdout

190+

.split("\n")

191+

.map((line) => line.trim())

192+

.filter((line) => line.length > 0)

193+

.map((file) => relative(process.cwd(), file).split(sep).join("/"))

194+

.toSorted();

195+

}

196+197+

function collectPublishablePluginPackages(): PublishablePluginPackage[] {

198+

return listPublishablePluginPackageDirs()

199+

.flatMap((packageDir) => {

138200

const packageJsonPath = join(packageDir, "package.json");

139201

let packageJson: {

140202

name?: unknown;

@@ -231,6 +293,21 @@ async function scanPublishablePluginPackage(plugin: PublishablePluginPackage): P

231293

}

232294233295

describe("publishable plugin npm package install security scan", () => {

296+

it("lists publishable plugin packages without scanning extension directories in-process", () => {

297+

const readDir = vi.spyOn(fs, "readdirSync");

298+

try {

299+

const packages = collectPublishablePluginPackages();

300+301+

expect(packages.length).toBeGreaterThan(0);

302+

expect(

303+

packages.every((plugin) => plugin.packageDir.split(sep).join("/").startsWith("extensions/")),

304+

).toBe(true);

305+

expect(readDir).not.toHaveBeenCalled();

306+

} finally {

307+

readDir.mockRestore();

308+

}

309+

});

310+234311

it("keeps npm-published plugin files clear of unexpected critical hits", async () => {

235312

const unexpectedCriticalFindings: string[] = [];

236313

const reviewedCriticalFindings = new Set<string>();