Skip to content

Commit

Permalink
Security issue: Snyk reports Path Traversal vulnerability in vectorma…
Browse files Browse the repository at this point in the history
…putils (T1250487, T1251419)
  • Loading branch information
EugeniyKiyashko committed Sep 19, 2024
1 parent fb6f86e commit 5c8b8ab
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/devextreme/js/viz/vector_map.utils/node-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ function normalizeJsName(value) {
return value.trim().replace('-', '_').replace(' ', '_');
}

function normalizePath(input) {
return path.normalize(input).replace(/[\. ]+$/, '');
}

function processFile(file, options, callback) {
var name = path.basename(file, path.extname(file));
options.info('%s: started', name);
Expand All @@ -20,8 +24,14 @@ function processFile(file, options, callback) {
if(!options.isJSON) {
content = options.processFileContent(content, normalizeJsName(name));
}

const baseDir = normalizePath(options.output) || path.dirname(file);
const fileName = normalizePath(options.processFileName(name + (options.isJSON ? '.json' : '.js')));

var outputPath = path.resolve(baseDir, fileName);

fs.writeFile(
path.resolve(options.output || path.dirname(file), options.processFileName(name + (options.isJSON ? '.json' : '.js'))),
outputPath,
content, function(e) {
e && options.error(' ' + e.message);
callback();
Expand All @@ -33,7 +43,8 @@ function processFile(file, options, callback) {
}

function collectFiles(dir, done) {
var input = path.resolve(dir || '');
var input = normalizePath(path.resolve(dir || ''));

fs.stat(input, function(e, stat) {
if(e) {
done(e, []);
Expand Down

0 comments on commit 5c8b8ab

Please sign in to comment.