mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
84c7d45f15
* refactor(qqbot): remove bundled extension source Mechanical deletion half of the #107295 squashed rebase; the catalog repoint and host integration land in the follow-up commit. Co-authored-by: sliverp <870080352@qq.com> * refactor(qqbot): install plugin from Tencent package Squashed rebase of #107295 onto current main. Repoints the official external channel catalog at @tencent-connect/openclaw-qqbot@2.0.1 and adapts onboarding, doctor migrations, secrets, build guards, and tests. Documents the known limitation that the external package does not support structured SecretRef clientSecret values; operators move those to QQBOT_CLIENT_SECRET or clientSecretFile before upgrading. Co-authored-by: sliverp <870080352@qq.com> * fix(doctor): reuse shared hasOwnKey record helper The rebased QQBot migration carried its own hasOwnKey export, colliding with the one main now ships in legacy-config-record-shared.ts. Co-authored-by: sliverp <870080352@qq.com> * fix(plugins): carry catalog integrity through the update bridge The externalized-bundled-plugin bridge dropped the official catalog's expectedIntegrity pin, so bundled-user updates installed the external npm package without integrity verification. The bridge now carries the pin for the catalog's exact npm spec and both bridge install calls pass it through; update-channel spec overrides intentionally skip the pin since it only covers the pinned version. Co-authored-by: sliverp <870080352@qq.com> * chore(plugin-sdk): refresh per-entrypoint API baselines The QQBot compat export and bundled-type removal shift 26 entrypoint closure hashes in the new split baseline layout. Co-authored-by: sliverp <870080352@qq.com> * refactor(qqbot): drop helper reintroduced during rebase Main's coercion consolidation added this file after the deletion commit's base; its only consumers were the removed qqbot sources. Co-authored-by: sliverp <870080352@qq.com> --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
106 lines
4.7 KiB
TypeScript
106 lines
4.7 KiB
TypeScript
#!/usr/bin/env node
|
|
|
|
// Blocks new raw fetch callsites in channel and plugin runtime sources.
|
|
import ts from "typescript";
|
|
import { bundledPluginCallsite } from "./lib/bundled-plugin-paths.mjs";
|
|
import { runCallsiteGuard } from "./lib/callsite-guard.mts";
|
|
import {
|
|
collectCallExpressionLines,
|
|
runAsScript,
|
|
unwrapExpression,
|
|
} from "./lib/ts-guard-utils.mts";
|
|
|
|
const sourceRoots = ["src/channels", "src/routing", "src/line", "extensions"];
|
|
|
|
// Temporary allowlist for legacy callsites. New raw fetch callsites in channel/plugin runtime
|
|
// code should be rejected and migrated to fetchWithSsrFGuard/shared channel helpers.
|
|
const allowedRawFetchCallsites = new Set([
|
|
bundledPluginCallsite("browser", "src/browser/cdp.helpers.ts", 268),
|
|
bundledPluginCallsite("browser", "src/browser/client-fetch.ts", 192),
|
|
bundledPluginCallsite("chutes", "models.ts", 536),
|
|
bundledPluginCallsite("chutes", "models.ts", 543),
|
|
bundledPluginCallsite("discord", "src/monitor/gateway-plugin.ts", 417),
|
|
bundledPluginCallsite("discord", "src/monitor/gateway-plugin.ts", 483),
|
|
bundledPluginCallsite("discord", "src/voice-message.ts", 298),
|
|
bundledPluginCallsite("discord", "src/voice-message.ts", 333),
|
|
bundledPluginCallsite("elevenlabs", "speech-provider.ts", 295),
|
|
bundledPluginCallsite("elevenlabs", "tts.ts", 74),
|
|
bundledPluginCallsite("feishu", "src/monitor.webhook.test-helpers.ts", 25),
|
|
bundledPluginCallsite("github-copilot", "login.ts", 80),
|
|
bundledPluginCallsite("github-copilot", "login.ts", 112),
|
|
bundledPluginCallsite("googlechat", "src/auth.ts", 83),
|
|
bundledPluginCallsite("huggingface", "models.ts", 143),
|
|
bundledPluginCallsite("kilocode", "provider-models.ts", 130),
|
|
bundledPluginCallsite("matrix", "src/matrix/sdk/transport.ts", 112),
|
|
bundledPluginCallsite("microsoft-foundry", "onboard.ts", 479),
|
|
bundledPluginCallsite("microsoft", "speech-provider.ts", 140),
|
|
bundledPluginCallsite("minimax", "oauth.ts", 82),
|
|
bundledPluginCallsite("minimax", "oauth.ts", 123),
|
|
bundledPluginCallsite("minimax", "tts.ts", 52),
|
|
bundledPluginCallsite("msteams", "src/graph.ts", 47),
|
|
bundledPluginCallsite("msteams", "src/sdk.ts", 400),
|
|
bundledPluginCallsite("msteams", "src/sdk.ts", 441),
|
|
bundledPluginCallsite("ollama", "src/stream.ts", 649),
|
|
bundledPluginCallsite("openai", "tts.ts", 149),
|
|
bundledPluginCallsite("qa-channel", "src/bus-client.ts", 41),
|
|
bundledPluginCallsite("qa-channel", "src/bus-client.ts", 221),
|
|
bundledPluginCallsite("qa-lab", "src/docker-up.runtime.ts", 274),
|
|
bundledPluginCallsite("qa-lab", "src/gateway-child.ts", 489),
|
|
bundledPluginCallsite("qa-lab", "src/suite.ts", 330),
|
|
bundledPluginCallsite("qa-lab", "src/suite.ts", 341),
|
|
// The QA dashboard calls its same-origin local API from the browser, where server SSRF helpers do not run.
|
|
bundledPluginCallsite("qa-lab", "web/src/http.ts", 24),
|
|
bundledPluginCallsite("qa-lab", "web/src/http.ts", 32),
|
|
bundledPluginCallsite("qa-lab", "web/src/http.ts", 43),
|
|
bundledPluginCallsite("signal", "src/install-signal-cli.ts", 224),
|
|
bundledPluginCallsite("slack", "src/monitor/media.ts", 106),
|
|
bundledPluginCallsite("slack", "src/monitor/media.ts", 125),
|
|
bundledPluginCallsite("slack", "src/monitor/media.ts", 130),
|
|
bundledPluginCallsite("venice", "models.ts", 552),
|
|
bundledPluginCallsite("vercel-ai-gateway", "models.ts", 181),
|
|
bundledPluginCallsite("voice-call", "src/providers/twilio/api.ts", 23),
|
|
]);
|
|
|
|
function isRawFetchCall(expression: ts.Expression) {
|
|
const callee = unwrapExpression(expression);
|
|
if (ts.isIdentifier(callee)) {
|
|
return callee.text === "fetch";
|
|
}
|
|
if (ts.isPropertyAccessExpression(callee)) {
|
|
return (
|
|
ts.isIdentifier(callee.expression) &&
|
|
callee.expression.text === "globalThis" &&
|
|
callee.name.text === "fetch"
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Finds raw `fetch(...)` and `globalThis.fetch(...)` call lines.
|
|
*/
|
|
function findRawFetchCallLines(content: string, fileName = "source.ts") {
|
|
const sourceFile = ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true);
|
|
return collectCallExpressionLines(ts, sourceFile, (node) =>
|
|
isRawFetchCall(node.expression) ? node.expression : null,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Runs the raw channel/plugin fetch guard.
|
|
*/
|
|
async function main() {
|
|
await runCallsiteGuard({
|
|
importMetaUrl: import.meta.url,
|
|
sourceRoots,
|
|
extraTestSuffixes: [".browser.test.ts", ".node.test.ts"],
|
|
findCallLines: findRawFetchCallLines,
|
|
skipRelativePath: (relPath) => relPath.includes("/test-support/"),
|
|
allowCallsite: (callsite) => allowedRawFetchCallsites.has(callsite),
|
|
header: "Found raw fetch() usage in channel/plugin runtime sources outside allowlist:",
|
|
footer: "Use fetchWithSsrFGuard() or existing channel/plugin SDK wrappers for network calls.",
|
|
});
|
|
}
|
|
|
|
runAsScript(import.meta.url, main);
|