Skip to content

Commit f1f6409

Browse files
Merge pull request #43 from contentstack/fix/DX-943-sre-vulnerability
dx | 943 sre vulnerability
2 parents 7093cb9 + e17f4f4 commit f1f6409

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/cleanup.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ const fs = require('fs');
33
const Path = require('path');
44
/* eslint-enable */
55

6-
const deleteFolderRecursive = (path) => {
6+
const sanitizePath = (inputPath) => {
7+
return Path.normalize(inputPath).replace(/^(\.\.(\/|\\|$))+/, '');
8+
};
9+
10+
const deleteFolderRecursive = (inputPath) => {
11+
const path = sanitizePath(inputPath);
12+
713
if (fs.existsSync(path)) {
814
fs.readdirSync(path).forEach((file) => {
9-
const curPath = Path.join(path, file);
15+
const curPath = Path.join(path, sanitizePath(file));
1016
if (fs.lstatSync(curPath).isDirectory()) {
1117
deleteFolderRecursive(curPath);
1218
} else {

0 commit comments

Comments
 (0)