mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:28:26 +00:00
fix(security): default-deny command execution
This commit is contained in:
@@ -45,3 +45,16 @@ export function isControlCommandMessage(
|
||||
const normalized = normalizeCommandBody(trimmed, options).trim().toLowerCase();
|
||||
return isAbortTrigger(normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Coarse detection for inline directives/shortcuts (e.g. "hey /status") so channel monitors
|
||||
* can decide whether to compute CommandAuthorized for a message.
|
||||
*
|
||||
* This intentionally errs on the side of false positives; CommandAuthorized only gates
|
||||
* command/directive execution, not normal chat replies.
|
||||
*/
|
||||
export function hasInlineCommandTokens(text?: string): boolean {
|
||||
const body = text ?? "";
|
||||
if (!body.trim()) return false;
|
||||
return /(?:^|\s)[/!][a-z]/i.test(body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user