Skip to content

Commit 4175d36

Browse files
committed
add test case
1 parent b727fa8 commit 4175d36

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const extract = tar.extract();
44

55
extract.on('entry', (header, stream, next) => {
66
const out = fs.createWriteStream(header.name);
7+
8+
if (header.linkname) {
9+
fs.linkSync(header.linkname, "foo");
10+
}
11+
712
stream.pipe(out);
813
stream.on('end', () => {
914
next();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ nodes
55
| TarSlipBad.js:6:36:6:46 | header.name |
66
| TarSlipBad.js:6:36:6:46 | header.name |
77
| TarSlipBad.js:6:36:6:46 | header.name |
8+
| TarSlipBad.js:9:17:9:31 | header.linkname |
9+
| TarSlipBad.js:9:17:9:31 | header.linkname |
10+
| TarSlipBad.js:9:17:9:31 | header.linkname |
811
| ZipSlipBad2.js:5:9:5:46 | fileName |
912
| ZipSlipBad2.js:5:20:5:46 | 'output ... ry.path |
1013
| ZipSlipBad2.js:5:37:5:46 | entry.path |
@@ -29,6 +32,7 @@ nodes
2932
edges
3033
| AdmZipBad.js:6:24:6:41 | zipEntry.entryName | AdmZipBad.js:6:24:6:41 | zipEntry.entryName |
3134
| TarSlipBad.js:6:36:6:46 | header.name | TarSlipBad.js:6:36:6:46 | header.name |
35+
| TarSlipBad.js:9:17:9:31 | header.linkname | TarSlipBad.js:9:17:9:31 | header.linkname |
3236
| ZipSlipBad2.js:5:9:5:46 | fileName | ZipSlipBad2.js:6:22:6:29 | fileName |
3337
| ZipSlipBad2.js:5:9:5:46 | fileName | ZipSlipBad2.js:6:22:6:29 | fileName |
3438
| ZipSlipBad2.js:5:20:5:46 | 'output ... ry.path | ZipSlipBad2.js:5:9:5:46 | fileName |
@@ -49,6 +53,7 @@ edges
4953
#select
5054
| AdmZipBad.js:6:24:6:41 | zipEntry.entryName | AdmZipBad.js:6:24:6:41 | zipEntry.entryName | AdmZipBad.js:6:24:6:41 | zipEntry.entryName | Unsanitized zip archive $@, which may contain '..', is used in a file system operation. | AdmZipBad.js:6:24:6:41 | zipEntry.entryName | item path |
5155
| TarSlipBad.js:6:36:6:46 | header.name | TarSlipBad.js:6:36:6:46 | header.name | TarSlipBad.js:6:36:6:46 | header.name | Unsanitized zip archive $@, which may contain '..', is used in a file system operation. | TarSlipBad.js:6:36:6:46 | header.name | item path |
56+
| TarSlipBad.js:9:17:9:31 | header.linkname | TarSlipBad.js:9:17:9:31 | header.linkname | TarSlipBad.js:9:17:9:31 | header.linkname | Unsanitized zip archive $@, which may contain '..', is used in a file system operation. | TarSlipBad.js:9:17:9:31 | header.linkname | item path |
5257
| ZipSlipBad2.js:6:22:6:29 | fileName | ZipSlipBad2.js:5:37:5:46 | entry.path | ZipSlipBad2.js:6:22:6:29 | fileName | Unsanitized zip archive $@, which may contain '..', is used in a file system operation. | ZipSlipBad2.js:5:37:5:46 | entry.path | item path |
5358
| ZipSlipBad.js:8:37:8:44 | fileName | ZipSlipBad.js:7:22:7:31 | entry.path | ZipSlipBad.js:8:37:8:44 | fileName | Unsanitized zip archive $@, which may contain '..', is used in a file system operation. | ZipSlipBad.js:7:22:7:31 | entry.path | item path |
5459
| ZipSlipBad.js:16:30:16:37 | fileName | ZipSlipBad.js:15:22:15:31 | entry.path | ZipSlipBad.js:16:30:16:37 | fileName | Unsanitized zip archive $@, which may contain '..', is used in a file system operation. | ZipSlipBad.js:15:22:15:31 | entry.path | item path |

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ var fs = {};
99
* @return {void}
1010
*/
1111
fs.writeFileSync = function(filename, data) {};
12+
13+
/**
14+
* @param {(string|Buffer)} srcpath
15+
* @param {(string|Buffer)} dstpath
16+
* @return {void}
17+
*/
18+
fs.linkSync = function(srcpath, dstpath) {};

0 commit comments

Comments
 (0)