Skip to content

Commit c8120ce

Browse files
authored
fix for issue 907
Directory check added
1 parent 97cd036 commit c8120ce

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/registry/routes/static-redirector.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ module.exports = function(repository) {
4646
res.errorDetails = `File ${filePath} not found`;
4747
return res.status(404).json({ err: res.errorDetails });
4848
}
49+
50+
const stats = fs.statSync(filePath);
51+
if (stats.isDirectory()) {
52+
res.errorDetails = 'Forbidden: Directory Listing Denied';
53+
return res.status(403).json({ err: res.errorDetails });
54+
}
4955

5056
const fileStream = fs.createReadStream(filePath),
5157
fileInfo = getFileInfo(filePath);

0 commit comments

Comments
 (0)