Skip to content

Commit 983ba92

Browse files
committed
Remove unnecessary path traversal checks
1 parent 0aa894f commit 983ba92

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

sarifLoader.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ async function getPathType(path) {
3232
async function getDirectoryFiles(inDirPath) {
3333
const dirents = await fs.readdir(inDirPath, { withFileTypes: true });
3434
const files = await Promise.all(dirents.map((dirent) => {
35-
// Check for possible path traversal attack and mitigate
36-
if (dirent.name.includes('..')) throw new Error('Invalid file name');
3735
const direntPath = path.resolve(inDirPath, dirent.name);
3836
return dirent.isDirectory() ? getDirectoryFiles(direntPath) : direntPath;
3937
}));
@@ -42,8 +40,6 @@ async function getDirectoryFiles(inDirPath) {
4240

4341
async function loadFile(inFilePath) {
4442
logger.debug(`Loading file: ${inFilePath}`);
45-
// Check for possible path traversal attack and mitigate
46-
if (inFilePath.includes('..')) throw new Error('Invalid file path');
4743
const sarifText = await fs.readFile(inFilePath, 'utf-8');
4844
const sarif = JSON.parse(sarifText);
4945
return sarif;

0 commit comments

Comments
 (0)