Skip to content

Commit b3e64f1

Browse files
committed
JS: Add test
1 parent 330c2c4 commit b3e64f1

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| query-tests/Security/CWE-022/TaintedPath/normalizedPaths.js:402 | did not expect an alert, but found an alert for TaintedPath | OK | |

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,9 @@ nodes
21292129
| normalizedPaths.js:399:21:399:24 | path |
21302130
| normalizedPaths.js:399:21:399:24 | path |
21312131
| normalizedPaths.js:399:21:399:24 | path |
2132+
| normalizedPaths.js:402:21:402:24 | path |
2133+
| normalizedPaths.js:402:21:402:24 | path |
2134+
| normalizedPaths.js:402:21:402:24 | path |
21322135
| other-fs-libraries.js:9:7:9:48 | path |
21332136
| other-fs-libraries.js:9:7:9:48 | path |
21342137
| other-fs-libraries.js:9:7:9:48 | path |
@@ -7019,6 +7022,10 @@ edges
70197022
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:399:21:399:24 | path |
70207023
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:399:21:399:24 | path |
70217024
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:399:21:399:24 | path |
7025+
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
7026+
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
7027+
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
7028+
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
70227029
| normalizedPaths.js:385:14:385:46 | pathMod ... uery.x) | normalizedPaths.js:385:7:385:46 | path |
70237030
| normalizedPaths.js:385:14:385:46 | pathMod ... uery.x) | normalizedPaths.js:385:7:385:46 | path |
70247031
| normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:385:14:385:46 | pathMod ... uery.x) |
@@ -9699,6 +9706,7 @@ edges
96999706
| normalizedPaths.js:381:19:381:29 | slash(path) | normalizedPaths.js:377:14:377:27 | req.query.path | normalizedPaths.js:381:19:381:29 | slash(path) | This path depends on $@. | normalizedPaths.js:377:14:377:27 | req.query.path | a user-provided value |
97009707
| normalizedPaths.js:388:19:388:22 | path | normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:388:19:388:22 | path | This path depends on $@. | normalizedPaths.js:385:35:385:45 | req.query.x | a user-provided value |
97019708
| normalizedPaths.js:399:21:399:24 | path | normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:399:21:399:24 | path | This path depends on $@. | normalizedPaths.js:385:35:385:45 | req.query.x | a user-provided value |
9709+
| normalizedPaths.js:402:21:402:24 | path | normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:402:21:402:24 | path | This path depends on $@. | normalizedPaths.js:385:35:385:45 | req.query.x | a user-provided value |
97029710
| other-fs-libraries.js:11:19:11:22 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:11:19:11:22 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |
97039711
| other-fs-libraries.js:12:27:12:30 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:12:27:12:30 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |
97049712
| other-fs-libraries.js:13:24:13:27 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:13:24:13:27 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |

javascript/ql/test/query-tests/Security/CWE-022/TaintedPath/normalizedPaths.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,4 +398,7 @@ app.get('/dotdot-regexp', (req, res) => {
398398
if (!path.match(/\.\.\/foo/)) {
399399
fs.readFileSync(path); // NOT OK
400400
}
401+
if (!path.match(/(\.\.\/|\.\.\\)/)) {
402+
fs.readFileSync(path); // OK
403+
}
401404
});

0 commit comments

Comments
 (0)