
























@@ -8626,6 +8626,104 @@ module.exports = {
86268626});
86278627});
862886288629+it("warns when plugins.allow entries do not match any discovered plugin ids", () => {
8630+useNoBundledPlugins();
8631+clearPluginLoaderCache();
8632+const { workspaceDir } = writeWorkspacePlugin({
8633+id: "warn-mismatch-allow-plugin",
8634+});
8635+const warnings: string[] = [];
8636+loadOpenClawPlugins({
8637+cache: false,
8638+ workspaceDir,
8639+logger: createWarningLogger(warnings),
8640+config: {
8641+plugins: {
8642+enabled: true,
8643+// User configured a channel-style id that does not match the real plugin id.
8644+allow: ["warn-mismatch-allow-channel"],
8645+},
8646+},
8647+});
8648+const emptyWarnings = warnings.filter((msg) => msg.includes("plugins.allow is empty"));
8649+const mismatchWarnings = warnings.filter((msg) =>
8650+msg.includes("do not match any discovered plugin ids"),
8651+);
8652+expect(emptyWarnings, "should not emit empty-allowlist warning").toHaveLength(0);
8653+expect(mismatchWarnings, "should emit mismatch warning once").toHaveLength(1);
8654+expect(mismatchWarnings[0]).toContain(`"warn-mismatch-allow-channel"`);
8655+expect(mismatchWarnings[0]).toContain("warn-mismatch-allow-plugin");
8656+expect(mismatchWarnings[0]).toContain("Use the plugin id");
8657+});
8658+8659+it("stays quiet when plugins.allow contains at least one matching plugin id", () => {
8660+useNoBundledPlugins();
8661+clearPluginLoaderCache();
8662+const { workspaceDir } = writeWorkspacePlugin({
8663+id: "warn-partial-allow-plugin",
8664+});
8665+const warnings: string[] = [];
8666+loadOpenClawPlugins({
8667+cache: false,
8668+ workspaceDir,
8669+logger: createWarningLogger(warnings),
8670+config: {
8671+plugins: {
8672+enabled: true,
8673+// Allow contains one real plugin id plus a stray channel-style entry.
8674+allow: ["warn-partial-allow-plugin", "warn-partial-allow-channel"],
8675+},
8676+},
8677+});
8678+const openAllowWarnings = warnings.filter(
8679+(msg) =>
8680+msg.includes("plugins.allow is empty") ||
8681+msg.includes("do not match any discovered plugin ids"),
8682+);
8683+expect(openAllowWarnings, "should not emit allowlist warning when one id matches").toHaveLength(
8684+0,
8685+);
8686+});
8687+8688+it("stays quiet when plugins.allow matches only bundled plugin ids, even while workspace/global plugins are present", () => {
8689+// Regression for Codex P2 feedback on #68389: the mismatch warning should be computed
8690+// against the full discovered plugin set (bundled + workspace + global), not only the
8691+// workspace/global subset that the warning talks about. An allowlist that intentionally
8692+// trusts bundled ids like ["telegram"] is valid and must not trip the mismatch path just
8693+// because some unrelated non-bundled plugin happens to be auto-discoverable.
8694+useNoBundledPlugins();
8695+clearPluginLoaderCache();
8696+writeBundledPlugin({
8697+id: "warn-bundled-allow-only-plugin",
8698+body: simplePluginBody("warn-bundled-allow-only-plugin"),
8699+});
8700+const { workspaceDir } = writeWorkspacePlugin({
8701+id: "warn-noise-workspace-plugin",
8702+});
8703+const warnings: string[] = [];
8704+loadOpenClawPlugins({
8705+cache: false,
8706+ workspaceDir,
8707+logger: createWarningLogger(warnings),
8708+config: {
8709+plugins: {
8710+enabled: true,
8711+// Allowlist intentionally only trusts a bundled plugin id.
8712+allow: ["warn-bundled-allow-only-plugin"],
8713+},
8714+},
8715+});
8716+const openAllowWarnings = warnings.filter(
8717+(msg) =>
8718+msg.includes("plugins.allow is empty") ||
8719+msg.includes("do not match any discovered plugin ids"),
8720+);
8721+expect(
8722+openAllowWarnings,
8723+"bundled-only allowlists should not trip the mismatch warning",
8724+).toHaveLength(0);
8725+});
8726+86298727it("handles workspace-discovered plugins according to trust and precedence", () => {
86308728useNoBundledPlugins();
86318729const scenarios = [
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。