mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-08 09:01:40 +00:00
Select default command-safety rules from the live session shell so legal PowerShell subexpressions are allowed and PowerShell-native dangerous commands are blocked. Untouched pre-shell-aware lists gain the new defaults on read. Closes #3256
24 lines
804 B
TypeScript
24 lines
804 B
TypeScript
import commandBlocklistTable from '../lib/commandBlocklist.json';
|
|
|
|
const LEGACY_DEFAULT_PATTERNS = [
|
|
...commandBlocklistTable.common,
|
|
...commandBlocklistTable.posixNative,
|
|
...commandBlocklistTable.posix,
|
|
];
|
|
|
|
/**
|
|
* Add PowerShell defaults only to a complete pre-shell-aware list.
|
|
* If any PowerShell default is already present, the list has been upgraded or
|
|
* customized and is left as saved.
|
|
*/
|
|
export function migrateLegacyCommandBlocklist(blocklist: string[]): string[] {
|
|
const configured = new Set(blocklist);
|
|
if (!LEGACY_DEFAULT_PATTERNS.every((pattern) => configured.has(pattern))) {
|
|
return blocklist;
|
|
}
|
|
if (commandBlocklistTable.powershell.some((pattern) => configured.has(pattern))) {
|
|
return blocklist;
|
|
}
|
|
return [...blocklist, ...commandBlocklistTable.powershell];
|
|
}
|