@@ -1,5 +1,8 @@
|
||||
const DANGEROUS_KEYS = new Set(['alt+f4', 'ctrl+q', 'ctrl+w', 'poweroff', 'reboot', 'shutdown']);
|
||||
export const isPasswordNode = (node) => /password|pam|credential/i.test(`${node?.role || ''} ${node?.name || ''}`);
|
||||
export const isDangerousKey = (combo) => DANGEROUS_KEYS.has(String(combo || '').toLowerCase().replace(/^key:/, ''));
|
||||
export function requiresConfirmation(action, target = {}) { return isDangerousKey(action) || /delete|format|purchase|send|install|power off|password|credential/i.test(`${action} ${target.name || ''} ${target.role || ''}`); }
|
||||
export function requiresConfirmation(action, target = {}) {
|
||||
if (isDangerousKey(action)) return true;
|
||||
return /\b(delete|format|purchase|install|power off|password|credential)\b/i.test(`${action} ${target.name || ''} ${target.role || ''}`);
|
||||
}
|
||||
export function assertSafeTarget(target) { if (isPasswordNode(target)) throw new Error('computer use refuses password or PAM controls'); }
|
||||
|
||||
Reference in New Issue
Block a user