fix(security): consume CLI policy approval once

This commit is contained in:
jesse-merhi
2026-08-11 01:37:39 +10:00
parent d6b8648a69
commit 2ebb077ae5
9 changed files with 98 additions and 15 deletions
+49
View File
@@ -1457,6 +1457,55 @@ describe("plugins cli update", () => {
expect(updateParams.onInstallPolicyWarning).toEqual(expect.any(Function));
});
it("shares one noninteractive install-policy acknowledgement across bulk plugin and hook updates", async () => {
setTty(false);
const config = createTrackedPluginConfig({
pluginId: "openclaw-codex-app-server",
spec: "openclaw-codex-app-server",
});
loadConfig.mockReturnValue(config);
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
setHookInstallRecords({
"demo-hooks": {
source: "npm",
spec: "@acme/demo-hooks@1.0.0",
installPath: "/tmp/hooks/demo-hooks",
},
});
primePluginUpdate(config);
updateNpmInstalledHookPacks.mockResolvedValue({
config,
changed: false,
outcomes: [],
});
await runPluginsCommand(["plugins", "update", "--all", "--acknowledge-install-policy-warning"]);
const pluginAcknowledgement =
expectSingleCallParams(updateNpmInstalledPlugins).onInstallPolicyWarning;
const hookAcknowledgement = expectSingleCallParams(
updateNpmInstalledHookPacks,
).onInstallPolicyWarning;
if (typeof pluginAcknowledgement !== "function") {
throw new Error("expected plugin install-policy acknowledgement callback");
}
expect(hookAcknowledgement).toBe(pluginAcknowledgement);
await expect(
pluginAcknowledgement({
targetName: "openclaw-codex-app-server",
targetType: "plugin",
requestMode: "update",
}),
).resolves.toBe(true);
await expect(
pluginAcknowledgement({
targetName: "demo-hooks",
targetType: "plugin",
requestMode: "update",
}),
).resolves.toBe(false);
});
it("writes updated config when updater reports changes", async () => {
const cfg = {
plugins: {