mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 05:40:22 +00:00
plugins: suppress provenance warning for allowlisted local plugins (#58604)
Co-authored-by: me <shlomo@vmi1916417.contaboserver.net>
This commit is contained in:
@@ -3633,7 +3633,7 @@ module.exports = {
|
||||
useNoBundledPlugins();
|
||||
const scenarios = [
|
||||
{
|
||||
label: "warns when loaded non-bundled plugin has no install/load-path provenance",
|
||||
label: "does not warn when loaded non-bundled plugin is in plugins.allow",
|
||||
loadRegistry: () => {
|
||||
return withStateDir((stateDir) => {
|
||||
const globalDir = path.join(stateDir, "extensions", "rogue");
|
||||
@@ -3656,6 +3656,35 @@ module.exports = {
|
||||
},
|
||||
});
|
||||
|
||||
return { registry, warnings, pluginId: "rogue", expectWarning: false };
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "warns when loaded non-bundled plugin has no provenance and no allowlist is set",
|
||||
loadRegistry: () => {
|
||||
const stateDir = makeTempDir();
|
||||
return withEnv({ OPENCLAW_STATE_DIR: stateDir }, () => {
|
||||
const globalDir = path.join(stateDir, "extensions", "rogue");
|
||||
mkdirSafe(globalDir);
|
||||
writePlugin({
|
||||
id: "rogue",
|
||||
body: `module.exports = { id: "rogue", register() {} };`,
|
||||
dir: globalDir,
|
||||
filename: "index.cjs",
|
||||
});
|
||||
|
||||
const warnings: string[] = [];
|
||||
const registry = loadOpenClawPlugins({
|
||||
cache: false,
|
||||
logger: createWarningLogger(warnings),
|
||||
config: {
|
||||
plugins: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return { registry, warnings, pluginId: "rogue", expectWarning: true };
|
||||
});
|
||||
},
|
||||
|
||||
@@ -773,13 +773,18 @@ function warnWhenAllowlistIsOpen(params: {
|
||||
function warnAboutUntrackedLoadedPlugins(params: {
|
||||
registry: PluginRegistry;
|
||||
provenance: PluginProvenanceIndex;
|
||||
allowlist: string[];
|
||||
logger: PluginLogger;
|
||||
env: NodeJS.ProcessEnv;
|
||||
}) {
|
||||
const allowSet = new Set(params.allowlist);
|
||||
for (const plugin of params.registry.plugins) {
|
||||
if (plugin.status !== "loaded" || plugin.origin === "bundled") {
|
||||
continue;
|
||||
}
|
||||
if (allowSet.has(plugin.id)) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
isTrackedByProvenance({
|
||||
pluginId: plugin.id,
|
||||
@@ -1391,6 +1396,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
warnAboutUntrackedLoadedPlugins({
|
||||
registry,
|
||||
provenance,
|
||||
allowlist: normalized.allow,
|
||||
logger,
|
||||
env,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user