refactor(security): unify command gating and blocked-key guards

This commit is contained in:
Peter Steinberger
2026-02-21 13:04:31 +01:00
parent 356d61aacf
commit 08e020881d
10 changed files with 111 additions and 58 deletions

View File

@@ -9,6 +9,7 @@ import { logVerbose } from "../../globals.js";
import { clampInt } from "../../utils.js";
import type { MsgContext } from "../templating.js";
import type { ReplyPayload } from "../types.js";
import { buildDisabledCommandReply } from "./command-gates.js";
import { formatElevatedUnavailableMessage } from "./elevated-unavailable.js";
import { stripMentions, stripStructuralPrefixes } from "./mentions.js";
@@ -188,9 +189,11 @@ export async function handleBashChatCommand(params: {
};
}): Promise<ReplyPayload> {
if (!isCommandFlagEnabled(params.cfg, "bash")) {
return {
text: "⚠️ bash is disabled. Set commands.bash=true to enable. Docs: https://docs.openclaw.ai/tools/slash-commands#config",
};
return buildDisabledCommandReply({
label: "bash",
configKey: "bash",
docsUrl: "https://docs.openclaw.ai/tools/slash-commands#config",
});
}
const agentId =