plugins: add before_install hook for install scanners

This commit is contained in:
George Zhang
2026-03-29 10:17:00 -07:00
parent 77555d6c85
commit 7cd9957f62
7 changed files with 267 additions and 18 deletions

View File

@@ -376,11 +376,14 @@ async function installBundleFromSourceDir(
}
try {
await runtime.scanBundleInstallSource({
const scanResult = await runtime.scanBundleInstallSource({
sourceDir: params.sourceDir,
pluginId,
logger,
});
if (scanResult?.blocked) {
return { ok: false, error: scanResult.blocked.reason };
}
} catch (err) {
logger.warn?.(
`Bundle "${pluginId}" code safety scan failed (${String(err)}). Installation continues; run "openclaw security audit --deep" after install.`,
@@ -545,12 +548,15 @@ async function installPluginFromPackageDir(
};
}
try {
await runtime.scanPackageInstallSource({
const scanResult = await runtime.scanPackageInstallSource({
packageDir: params.packageDir,
pluginId,
logger,
extensions,
});
if (scanResult?.blocked) {
return { ok: false, error: scanResult.blocked.reason };
}
} catch (err) {
logger.warn?.(
`Plugin "${pluginId}" code safety scan failed (${String(err)}). Installation continues; run "openclaw security audit --deep" after install.`,