Skip to content

Commit 2a2cd20

Browse files
fix(plugin-sdk): scope facade verifier artifact scan
1 parent b9f8e1b commit 2a2cd20

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

scripts/openclaw-npm-postpublish-verify.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const MAX_INSTALLED_ROOT_PACKAGE_JSON_BYTES = 1024 * 1024;
6161
const MAX_INSTALLED_ROOT_DIST_JS_BYTES = 6 * 1024 * 1024;
6262
const MAX_INSTALLED_ROOT_DIST_JS_FILES = 5000;
6363
const ROOT_DIST_JAVASCRIPT_MODULE_FILE_RE = /\.(?:c|m)?js$/u;
64+
const INSTALLED_FACADE_ACTIVATION_RUNTIME_RELATIVE_PATH_RE =
65+
/^facade-activation-check\.runtime\.(?:c|m)?js$/u;
6466
const OPTIONAL_OR_EXTERNALIZED_RUNTIME_IMPORTS = new Set([
6567
// Optional A2UI markdown renderer. The Canvas host bundle catches the missing
6668
// package and falls back when the optional renderer is unavailable.
@@ -350,6 +352,15 @@ function listInstalledRootDistJavaScriptFiles(packageRoot: string): string[] {
350352
});
351353
}
352354

355+
function listInstalledFacadeActivationRuntimeFiles(packageRoot: string): string[] {
356+
const distRoot = join(packageRoot, "dist");
357+
return listInstalledRootDistJavaScriptFiles(packageRoot).filter((filePath) =>
358+
INSTALLED_FACADE_ACTIVATION_RUNTIME_RELATIVE_PATH_RE.test(
359+
relative(distRoot, filePath).replaceAll("\\", "/"),
360+
),
361+
);
362+
}
363+
353364
type ParsedImportSpecifiersResult =
354365
| { ok: true; specifiers: Set<string> }
355366
| { ok: false; error: string };
@@ -525,7 +536,7 @@ function isSafeBundledRuntimeFacadeDirName(value: string): boolean {
525536

526537
export function collectInstalledAlwaysAllowedRuntimeFacadeErrors(packageRoot: string): string[] {
527538
const errors: string[] = [];
528-
for (const filePath of listInstalledRootDistJavaScriptFiles(packageRoot)) {
539+
for (const filePath of listInstalledFacadeActivationRuntimeFiles(packageRoot)) {
529540
const fileStat = lstatSync(filePath);
530541
const relativePath = relative(packageRoot, filePath).replaceAll("\\", "/");
531542
if (!fileStat.isFile() || fileStat.size > MAX_INSTALLED_ROOT_DIST_JS_BYTES) {

test/openclaw-npm-postpublish-verify.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ describe("collectInstalledAlwaysAllowedRuntimeFacadeErrors", () => {
163163
expect(collectInstalledAlwaysAllowedRuntimeFacadeErrors(packageRoot)).toStrictEqual([]);
164164
});
165165
});
166+
167+
it("ignores oversized non-facade root dist files", () => {
168+
withInstalledPackageRoot((packageRoot) => {
169+
writeInstalledFile(
170+
packageRoot,
171+
"dist/typescript-compiler.js",
172+
"x".repeat(6 * 1024 * 1024 + 1),
173+
);
174+
175+
expect(collectInstalledAlwaysAllowedRuntimeFacadeErrors(packageRoot)).toStrictEqual([]);
176+
});
177+
});
166178
});
167179

168180
describe("collectInstalledContextEngineRuntimeErrors", () => {

0 commit comments

Comments
 (0)