Skip to content

Commit ec72e5e

Browse files
Security issue: Snyk reports Path Traversal vulnerability in vectormaputils (T1250487, T1251419)
1 parent fb6f86e commit ec72e5e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/devextreme/js/viz/vector_map.utils/node-cmd.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ function normalizeJsName(value) {
66
return value.trim().replace('-', '_').replace(' ', '_');
77
}
88

9+
function normalizePath(input) {
10+
return path.normalize(input).replace(/[\. ]+$/, '');
11+
}
12+
913
function processFile(file, options, callback) {
1014
var name = path.basename(file, path.extname(file));
1115
options.info('%s: started', name);
@@ -20,8 +24,14 @@ function processFile(file, options, callback) {
2024
if(!options.isJSON) {
2125
content = options.processFileContent(content, normalizeJsName(name));
2226
}
27+
28+
const baseDir = normalizePath(options.output) || path.dirname(file);
29+
const fileName = normalizePath(options.processFileName(name + (options.isJSON ? '.json' : '.js')))
30+
31+
var outputPath = path.resolve(baseDir, fileName);
32+
2333
fs.writeFile(
24-
path.resolve(options.output || path.dirname(file), options.processFileName(name + (options.isJSON ? '.json' : '.js'))),
34+
outputPath,
2535
content, function(e) {
2636
e && options.error(' ' + e.message);
2737
callback();
@@ -33,7 +43,8 @@ function processFile(file, options, callback) {
3343
}
3444

3545
function collectFiles(dir, done) {
36-
var input = path.resolve(dir || '');
46+
var input = normalizePath(path.resolve(dir || ''));
47+
3748
fs.stat(input, function(e, stat) {
3849
if(e) {
3950
done(e, []);

0 commit comments

Comments
 (0)