( parsed: ParsedPowerShellCommand, )
| 849 | ]) |
| 850 | |
| 851 | function checkScheduledTask( |
| 852 | parsed: ParsedPowerShellCommand, |
| 853 | ): PowerShellSecurityResult { |
| 854 | for (const cmd of getAllCommands(parsed)) { |
| 855 | const lower = cmd.name.toLowerCase() |
| 856 | if (SCHEDULED_TASK_CMDLETS.has(lower)) { |
| 857 | return { |
| 858 | behavior: 'ask', |
| 859 | message: `${cmd.name} creates or modifies a scheduled task (persistence primitive)`, |
| 860 | } |
| 861 | } |
| 862 | if (lower === 'schtasks' || lower === 'schtasks.exe') { |
| 863 | if ( |
| 864 | cmd.args.some(a => { |
| 865 | const la = a.toLowerCase() |
| 866 | return ( |
| 867 | la === '/create' || |
| 868 | la === '/change' || |
| 869 | la === '-create' || |
| 870 | la === '-change' |
| 871 | ) |
| 872 | }) |
| 873 | ) { |
| 874 | return { |
| 875 | behavior: 'ask', |
| 876 | message: |
| 877 | 'schtasks with create/change modifies scheduled tasks (persistence primitive)', |
| 878 | } |
| 879 | } |
| 880 | } |
| 881 | } |
| 882 | return { behavior: 'passthrough' } |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * AST-only check: Detects environment variable manipulation via Set-Item/New-Item on env: scope. |
nothing calls this directly
no test coverage detected