Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8829fde

Browse files
committed
JS: Add test for zipslip basename sanitization.
1 parent 126e207 commit 8829fde

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require('fs');
2+
const unzip = require('unzip');
3+
const path = require('path');
4+
5+
fs.createReadStream('archive.zip')
6+
.pipe(unzip.Parse())
7+
.on('entry', entry => {
8+
const fileName = entry.path;
9+
entry.pipe(fs.createWriteStream(path.join('my_directory', path.basename(fileName))));
10+
});

0 commit comments

Comments
 (0)