Skip to content

Commit 5a5192b

Browse files
committed
add testing for complex path sanitizer in ZipSlip
1 parent 0d76206 commit 5a5192b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-022/ZipSlip/ZipSlipGood.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ fs.createReadStream('archive.zip')
1515

1616
fs.createWriteStream(path.join(cwd, path.join('/', fileName)));
1717
});
18+
19+
fs.createReadStream('archive.zip')
20+
.pipe(unzip.Parse())
21+
.on('entry', entry => {
22+
const fileName = path.normalize(entry.path);
23+
24+
if (path.isAbsolute(fileName)) {
25+
return;
26+
}
27+
28+
if (!fileName.startsWith(".")) {
29+
entry.pipe(fs.createWriteStream(fileName)); // OK.
30+
}
31+
});

0 commit comments

Comments
 (0)