Skip to content

Commit b9f1c1c

Browse files
committed
fix(utils): resolve command injection vulnerability in emptyFolder
1 parent 53a5a97 commit b9f1c1c

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
@@ -457,7 +457,10 @@ module.exports.isNotSet = function (obj) {
457457
};
458458

459459
module.exports.emptyFolder = (directoryPath) => {
460-
require('child_process').execSync(`rm -rf ${directoryPath}/*`);
460+
if (!fs.existsSync(directoryPath)) return;
461+
for (const file of fs.readdirSync(directoryPath)) {
462+
fs.rmSync(path.join(directoryPath, file), { recursive: true, force: true });
463+
}
461464
};
462465

463466
module.exports.printObjectProperties = (obj) => {

0 commit comments

Comments
 (0)