Skip to content

Commit c96ca5b

Browse files
committed
fix(utils): resolve command injection vulnerability in emptyFolder
1 parent 1ad971c commit c96ca5b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,11 @@ module.exports.isNotSet = function (obj) {
477477
}
478478

479479
module.exports.emptyFolder = directoryPath => {
480-
require('child_process').execSync(`rm -rf ${directoryPath}/*`)
480+
// Do not throw on non-existent directory, since it may be created later
481+
if (!fs.existsSync(directoryPath)) return
482+
for (const file of fs.readdirSync(directoryPath)) {
483+
fs.rmSync(path.join(directoryPath, file), { recursive: true, force: true })
484+
}
481485
}
482486

483487
module.exports.printObjectProperties = obj => {

0 commit comments

Comments
 (0)