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

@@ -1,5 +1,5 @@
import { logVerbose } from "../../globals.js";
import { handleBashChatCommand } from "./bash-command.js";
import { rejectUnauthorizedCommand } from "./command-gates.js";
import type { CommandHandler } from "./commands-types.js";
export const handleBashCommand: CommandHandler = async (params, allowTextCommands) => {
@@ -13,9 +13,9 @@ export const handleBashCommand: CommandHandler = async (params, allowTextCommand
if (!bashSlashRequested && !(bashBangRequested && command.isAuthorizedSender)) {
return null;
}
if (!command.isAuthorizedSender) {
logVerbose(`Ignoring /bash from unauthorized sender: ${command.senderId || "<unknown>"}`);
return { shouldContinue: false };
const unauthorized = rejectUnauthorizedCommand(params, "/bash");
if (unauthorized) {
return unauthorized;
}
const reply = await handleBashChatCommand({
ctx: params.ctx,