Skip to content

Commit 82cc04b

Browse files
committed
Removes false positive on non-win32 platforms
1 parent 1c92d69 commit 82cc04b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/cli/commands/policies.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* @flow */
2+
/* eslint-disable max-len */
23

34
import type {Reporter} from '../../reporters/index.js';
45
import type Config from '../../config.js';

src/util/child.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ export const exec = promisify(child.exec);
1919

2020
function validate(program: string, opts?: Object = {}) {
2121
if (program.includes('/')) {
22-
return true;
22+
return;
2323
}
2424

25-
const cwd = opts.cwd || process.cwd();
26-
const pathext = process.env.PATHEXT || '';
25+
if (process.platform === 'win32' && process.env.PATHEXT) {
26+
const cwd = opts.cwd || process.cwd();
27+
const pathext = process.env.PATHEXT;
2728

28-
for (const ext of pathext.split(';')) {
29-
const candidate = path.join(cwd, `${program}${ext}`);
30-
if (fs.existsSync(candidate)) {
31-
throw new Error(`Potentially dangerous call to "${program}" in ${cwd}`);
29+
for (const ext of pathext.split(';')) {
30+
const candidate = path.join(cwd, `${program}${ext}`);
31+
if (fs.existsSync(candidate)) {
32+
throw new Error(`Potentially dangerous call to "${program}" in ${cwd}`);
33+
}
3234
}
3335
}
3436
}

0 commit comments

Comments
 (0)