@@ -12,6 +12,12 @@ const fixture = fixtures.path('exit.js');
12
12
const echoFixture = fixtures . path ( 'echo.js' ) ;
13
13
const execOpts = { encoding : 'utf8' , shell : true , env : { ...process . env , NODE : process . execPath , FIXTURE : fixture } } ;
14
14
15
+ common . expectWarning (
16
+ 'DeprecationWarning' ,
17
+ 'Passing args to a child process with shell option true can lead to security ' +
18
+ 'vulnerabilities, as the arguments are not escaped, only concatenated.' ,
19
+ 'DEP0190' ) ;
20
+
15
21
{
16
22
execFile (
17
23
process . execPath ,
@@ -47,7 +53,8 @@ const execOpts = { encoding: 'utf8', shell: true, env: { ...process.env, NODE: p
47
53
{
48
54
// Verify the shell option works properly
49
55
execFile (
50
- common . isWindows ? `"${ execOpts . env . NODE } " "${ execOpts . env . FIXTURE } 0` : `"$NODE" "$FIXTURE" 0` ,
56
+ `"${ common . isWindows ? execOpts . env . NODE : '$NODE' } "` ,
57
+ [ `"${ common . isWindows ? execOpts . env . FIXTURE : '$FIXTURE' } "` , 0 ] ,
51
58
execOpts ,
52
59
common . mustSucceed ( ) ,
53
60
) ;
@@ -116,14 +123,10 @@ const execOpts = { encoding: 'utf8', shell: true, env: { ...process.env, NODE: p
116
123
...( common . isWindows ? [ ] : [ { encoding : 'utf8' } ] ) ,
117
124
{ shell : true , encoding : 'utf8' } ,
118
125
] . forEach ( ( options ) => {
119
- const command = options . shell ?
120
- [ [ file , ...args ] . join ( ' ' ) ] :
121
- [ file , args ] ;
122
-
123
- const execFileSyncStdout = execFileSync ( ...command , options ) ;
126
+ const execFileSyncStdout = execFileSync ( file , args , options ) ;
124
127
assert . strictEqual ( execFileSyncStdout , `foo bar${ os . EOL } ` ) ;
125
128
126
- execFile ( ... command , options , common . mustCall ( ( _ , stdout ) => {
129
+ execFile ( file , args , options , common . mustCall ( ( _ , stdout ) => {
127
130
assert . strictEqual ( stdout , execFileSyncStdout ) ;
128
131
} ) ) ;
129
132
} ) ;
0 commit comments