Skip to content

Commit f27ad44

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

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/utils.js

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

479479
module.exports.emptyFolder = directoryPath => {
480-
require('child_process').execSync(`rm -rf ${directoryPath}/*`)
480+
if (!fs.existsSync(directoryPath)) return
481+
for (const file of fs.readdirSync(directoryPath)) {
482+
fs.rmSync(path.join(directoryPath, file), { recursive: true, force: true })
483+
}
481484
}
482485

483486
module.exports.printObjectProperties = obj => {

0 commit comments

Comments
 (0)