fix(plugins): preserve bundled allowlist edges · openclaw/openclaw@40e0844
steipete
·
2026-05-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -02987f4cecb64a98170b61c925fd7b16a22b276abfb261f9281b42f613ded923 config-baseline.json |
2 | | -de5a6f65ef09dc23453a2e12512e41c133c941519e0ebef7f2946e4a24265d17 config-baseline.core.json |
| 1 | +2566cb33c48abf3884d44cc605e3fe23ee3dc3e998c29fe86dfe773faf58cb52 config-baseline.json |
| 2 | +eab2f8a9af31910e26874209330d10ca46afd910cba88beda8a48fe6b9831159 config-baseline.core.json |
3 | 3 | cd7c0c7fb1435bc7e59099e9ac334462d5ad444016e9ab4512aae63a238f78dc config-baseline.channel.json |
4 | 4 | 9832b30a696930a3da7efccf38073137571e1b66cae84e54d747b733fdafcc54 config-baseline.plugin.json |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -132,6 +132,27 @@ describe("implicit provider plugin allowlist compatibility", () => {
|
132 | 132 | ).toEqual(["openrouter"]); |
133 | 133 | }); |
134 | 134 | |
| 135 | +it("does not re-enable plugins when allowlist mode rejects every compat plugin", () => { |
| 136 | +const config = withBundledPluginEnablementCompat({ |
| 137 | +config: { |
| 138 | +plugins: { |
| 139 | +enabled: false, |
| 140 | +allow: ["openrouter"], |
| 141 | +bundledDiscovery: "allowlist", |
| 142 | +}, |
| 143 | +}, |
| 144 | +pluginIds: ["kilocode", "moonshot"], |
| 145 | +}); |
| 146 | + |
| 147 | +expect(config).toEqual({ |
| 148 | +plugins: { |
| 149 | +enabled: false, |
| 150 | +allow: ["openrouter"], |
| 151 | +bundledDiscovery: "allowlist", |
| 152 | +}, |
| 153 | +}); |
| 154 | +}); |
| 155 | + |
135 | 156 | it("still honors explicit plugin denies over compat allowlist injection", () => { |
136 | 157 | const config = withBundledPluginEnablementCompat({ |
137 | 158 | config: withBundledPluginAllowlistCompat({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -46,22 +46,24 @@ export function withBundledPluginEnablementCompat(params: {
|
46 | 46 | const allow = params.config?.plugins?.allow; |
47 | 47 | const allowSet = |
48 | 48 | !useCompatDiscovery && Array.isArray(allow) && allow.length > 0 ? new Set(allow) : undefined; |
| 49 | +let hasEligiblePlugin = false; |
49 | 50 | let changed = false; |
50 | 51 | const nextEntries: Record<string, PluginEntryConfig> = { ...existingEntries }; |
51 | 52 | |
52 | 53 | for (const pluginId of params.pluginIds) { |
53 | | -if (existingEntries[pluginId] !== undefined) { |
| 54 | +if (allowSet && !allowSet.has(pluginId)) { |
54 | 55 | continue; |
55 | 56 | } |
56 | | -if (allowSet && !allowSet.has(pluginId)) { |
| 57 | +hasEligiblePlugin = true; |
| 58 | +if (existingEntries[pluginId] !== undefined) { |
57 | 59 | continue; |
58 | 60 | } |
59 | 61 | nextEntries[pluginId] = { enabled: true }; |
60 | 62 | changed = true; |
61 | 63 | } |
62 | 64 | |
63 | 65 | if (!changed) { |
64 | | -if (!forcePluginsEnabled) { |
| 66 | +if (!forcePluginsEnabled || !hasEligiblePlugin) { |
65 | 67 | return params.config; |
66 | 68 | } |
67 | 69 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -152,4 +152,37 @@ describe("web provider public artifact manifest fallback", () => {
|
152 | 152 | pluginId: "fallback-fetch", |
153 | 153 | }); |
154 | 154 | }); |
| 155 | + |
| 156 | +it("matches bundled web-search candidates through provider alias allowlist entries", () => { |
| 157 | +mocks.resolveBundledExplicitWebSearchProvidersFromPublicArtifacts.mockReturnValueOnce(null); |
| 158 | +mocks.loadPluginMetadataSnapshot.mockReturnValueOnce({ |
| 159 | +diagnostics: [], |
| 160 | +plugins: [ |
| 161 | +{ |
| 162 | +id: "google", |
| 163 | +origin: "bundled", |
| 164 | +rootDir: "/tmp/google", |
| 165 | +contracts: { webSearchProviders: ["gemini"] }, |
| 166 | +}, |
| 167 | +], |
| 168 | +}); |
| 169 | +mocks.loadBundledWebSearchProviderEntriesFromDir.mockReturnValueOnce([ |
| 170 | +{ id: "gemini", pluginId: "google" }, |
| 171 | +]); |
| 172 | + |
| 173 | +const providers = resolveBundledWebSearchProvidersFromPublicArtifacts({ |
| 174 | +config: { |
| 175 | +plugins: { |
| 176 | +allow: ["google-gemini-cli"], |
| 177 | +bundledDiscovery: "allowlist", |
| 178 | +}, |
| 179 | +}, |
| 180 | +}); |
| 181 | + |
| 182 | +expect(providers).toEqual([{ id: "gemini", pluginId: "google" }]); |
| 183 | +expect(mocks.loadBundledWebSearchProviderEntriesFromDir).toHaveBeenCalledWith({ |
| 184 | +dirName: "google", |
| 185 | +pluginId: "google", |
| 186 | +}); |
| 187 | +}); |
155 | 188 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import path from "node:path"; |
| 2 | +import { normalizePluginId } from "./config-state.js"; |
2 | 3 | import type { PluginLoadOptions } from "./loader.js"; |
3 | 4 | import { loadManifestMetadataSnapshot } from "./manifest-contract-eligibility.js"; |
4 | 5 | import type { PluginManifestRecord } from "./manifest-registry.js"; |
@@ -38,7 +39,9 @@ function filterAllowlistedBundledPluginIds(
|
38 | 39 | ) { |
39 | 40 | return [...pluginIds]; |
40 | 41 | } |
41 | | -const allowedPluginIds = new Set(allow.map((pluginId) => pluginId.trim()).filter(Boolean)); |
| 42 | +const allowedPluginIds = new Set( |
| 43 | +allow.map((pluginId) => normalizePluginId(pluginId)).filter(Boolean), |
| 44 | +); |
42 | 45 | return pluginIds.filter((pluginId) => allowedPluginIds.has(pluginId)); |
43 | 46 | } |
44 | 47 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。