MCPcopy Create free account
hub / github.com/freecodexyz/free-code / checkScheduledTask

Function checkScheduledTask

src/tools/PowerShellTool/powershellSecurity.ts:851–883  ·  view source on GitHub ↗
(
  parsed: ParsedPowerShellCommand,
)

Source from the content-addressed store, hash-verified

849])
850
851function 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.

Callers

nothing calls this directly

Calls 2

getAllCommandsFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected