1+ import { execa , execaSync , execaCommand , execaCommandSync , $ } from 'execa' ;
2+ import http from 'node:http'
3+ import url from 'url'
4+
5+ http . createServer ( async function ( req , res ) {
6+ let cmd = url . parse ( req . url , true ) . query [ "cmd" ] [ 0 ] ;
7+ let arg1 = url . parse ( req . url , true ) . query [ "arg1" ] ;
8+ let arg2 = url . parse ( req . url , true ) . query [ "arg2" ] ;
9+ let arg3 = url . parse ( req . url , true ) . query [ "arg3" ] ;
10+
11+ await $ `${ cmd } ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
12+ await $ `ssh ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
13+ $ ( { shell : false } ) . sync `${ cmd } ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
14+ $ ( { shell : true } ) . sync `${ cmd } ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
15+ $ ( { shell : false } ) . sync `ssh ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
16+
17+ $ . sync `${ cmd } ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
18+ $ . sync `ssh ${ arg1 } ${ arg2 } ${ arg3 } ` ; // test: CommandInjection
19+ await $ ( { shell : true } ) `${ cmd } ${ arg1 } ${ arg2 } ${ arg3 } ` // test: CommandInjection
20+ await $ ( { shell : false } ) `${ cmd } ${ arg1 } ${ arg2 } ${ arg3 } ` // test: CommandInjection
21+ await $ ( { shell : false } ) `ssh ${ arg1 } ${ arg2 } ${ arg3 } ` // test: CommandInjection
22+
23+ await execa ( cmd , [ arg1 , arg2 , arg3 ] ) ; // test: CommandInjection
24+ await execa ( cmd , { shell : true } ) ; // test: CommandInjection
25+ await execa ( cmd , { shell : true } ) ; // test: CommandInjection
26+ await execa ( cmd , [ arg1 , arg2 , arg3 ] , { shell : true } ) ; // test: CommandInjection
27+
28+ execaSync ( cmd , [ arg1 , arg2 , arg3 ] ) ; // test: CommandInjection
29+ execaSync ( cmd , [ arg1 , arg2 , arg3 ] , { shell : true } ) ; // test: CommandInjection
30+
31+ await execaCommand ( cmd + arg1 + arg2 + arg3 ) ; // test: CommandInjection
32+ await execaCommand ( cmd + arg1 + arg2 + arg3 , { shell : true } ) ; // test: CommandInjection
33+
34+ execaCommandSync ( cmd + arg1 + arg2 + arg3 ) ; // test: CommandInjection
35+ execaCommandSync ( cmd + arg1 + arg2 + arg3 , { shell : true } ) ; // test: CommandInjection
36+ } ) ;
0 commit comments