2026-07-07 16:31:34 -04:00
|
|
|
import { ALLOWED_COMMANDS } from "@tasks/shared/worker";
|
|
|
|
|
|
2026-08-25 17:20:53 -04:00
|
|
|
export function isAllowedCommand(
|
|
|
|
|
command: string,
|
|
|
|
|
allowedCommands?: readonly string[] | null,
|
|
|
|
|
): boolean {
|
|
|
|
|
const allowList = allowedCommands === undefined || allowedCommands === null ? ALLOWED_COMMANDS : allowedCommands;
|
|
|
|
|
if (allowList.length === 0) return false;
|
2026-07-07 16:31:34 -04:00
|
|
|
const normalized = command.trim().replace(/\s+/g, " ");
|
2026-08-25 17:20:53 -04:00
|
|
|
return allowList.some((allowed) => normalized === allowed || normalized.startsWith(`${allowed} `));
|
2026-07-07 16:31:34 -04:00
|
|
|
}
|