mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 23:00:22 +00:00
Tests: tighten channel import guardrails
This commit is contained in:
@@ -9,7 +9,11 @@ const ALLOWED_EXTENSION_PUBLIC_SURFACES = new Set([
|
|||||||
"action-runtime-api.js",
|
"action-runtime-api.js",
|
||||||
"api.js",
|
"api.js",
|
||||||
"index.js",
|
"index.js",
|
||||||
|
"light-runtime-api.js",
|
||||||
"login-qr-api.js",
|
"login-qr-api.js",
|
||||||
|
"onboard.js",
|
||||||
|
"openai-codex-catalog.js",
|
||||||
|
"provider-catalog.js",
|
||||||
"runtime-api.js",
|
"runtime-api.js",
|
||||||
"session-key-api.js",
|
"session-key-api.js",
|
||||||
"setup-api.js",
|
"setup-api.js",
|
||||||
@@ -252,6 +256,7 @@ function collectCoreSourceFiles(): string[] {
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
fullPath.includes(".test.") ||
|
fullPath.includes(".test.") ||
|
||||||
|
fullPath.includes(".mock-harness.") ||
|
||||||
fullPath.includes(".spec.") ||
|
fullPath.includes(".spec.") ||
|
||||||
fullPath.includes(".fixture.") ||
|
fullPath.includes(".fixture.") ||
|
||||||
fullPath.includes(".snap") ||
|
fullPath.includes(".snap") ||
|
||||||
@@ -320,11 +325,14 @@ function collectImportSpecifiers(text: string): string[] {
|
|||||||
function expectOnlyApprovedExtensionSeams(file: string, imports: string[]): void {
|
function expectOnlyApprovedExtensionSeams(file: string, imports: string[]): void {
|
||||||
for (const specifier of imports) {
|
for (const specifier of imports) {
|
||||||
const normalized = specifier.replaceAll("\\", "/");
|
const normalized = specifier.replaceAll("\\", "/");
|
||||||
const extensionId = normalized.match(/extensions\/([^/]+)\//)?.[1] ?? null;
|
const resolved = specifier.startsWith(".")
|
||||||
|
? resolve(dirname(file), specifier).replaceAll("\\", "/")
|
||||||
|
: normalized;
|
||||||
|
const extensionId = resolved.match(/extensions\/([^/]+)\//)?.[1] ?? null;
|
||||||
if (!extensionId || !GUARDED_CHANNEL_EXTENSIONS.has(extensionId)) {
|
if (!extensionId || !GUARDED_CHANNEL_EXTENSIONS.has(extensionId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const basename = normalized.split("/").at(-1) ?? "";
|
const basename = resolved.split("/").at(-1) ?? "";
|
||||||
expect(
|
expect(
|
||||||
ALLOWED_EXTENSION_PUBLIC_SURFACES.has(basename),
|
ALLOWED_EXTENSION_PUBLIC_SURFACES.has(basename),
|
||||||
`${file} should only import approved extension surfaces, got ${specifier}`,
|
`${file} should only import approved extension surfaces, got ${specifier}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user