Skip to content

Commit 65da9b4

Browse files
committed
JS: Add cross-file test in InsecureRandom
1 parent b4bd8e7 commit 65da9b4

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-338/InsecureRandomness.expected

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
edges
2+
| foo.js:5:12:5:22 | getRandom() | library2.js:1:24:1:25 | pw | provenance | |
3+
| library1.js:2:12:2:24 | Math.random() | foo.js:5:12:5:22 | getRandom() | provenance | |
4+
| library2.js:1:24:1:25 | pw | library2.js:2:20:2:21 | pw | provenance | |
25
| tst.js:6:31:6:43 | Math.random() | tst.js:6:20:6:43 | "prefix ... andom() | provenance | Config |
36
| tst.js:19:9:19:36 | suffix | tst.js:20:31:20:36 | suffix | provenance | |
47
| tst.js:19:18:19:30 | Math.random() | tst.js:19:18:19:36 | Math.random() % 255 | provenance | Config |
@@ -32,6 +35,10 @@ edges
3235
| tst.js:136:38:136:50 | Math.random() | tst.js:136:38:136:65 | Math.ra ... .length | provenance | Config |
3336
| tst.js:136:38:136:65 | Math.ra ... .length | tst.js:136:27:136:66 | Math.fl ... length) | provenance | Config |
3437
nodes
38+
| foo.js:5:12:5:22 | getRandom() | semmle.label | getRandom() |
39+
| library1.js:2:12:2:24 | Math.random() | semmle.label | Math.random() |
40+
| library2.js:1:24:1:25 | pw | semmle.label | pw |
41+
| library2.js:2:20:2:21 | pw | semmle.label | pw |
3542
| tst.js:2:20:2:32 | Math.random() | semmle.label | Math.random() |
3643
| tst.js:6:20:6:43 | "prefix ... andom() | semmle.label | "prefix ... andom() |
3744
| tst.js:6:31:6:43 | Math.random() | semmle.label | Math.random() |
@@ -89,6 +96,7 @@ nodes
8996
| tst.js:136:38:136:65 | Math.ra ... .length | semmle.label | Math.ra ... .length |
9097
subpaths
9198
#select
99+
| library2.js:2:20:2:21 | pw | library1.js:2:12:2:24 | Math.random() | library2.js:2:20:2:21 | pw | This uses a cryptographically insecure random number generated at $@ in a security context. | library1.js:2:12:2:24 | Math.random() | Math.random() |
92100
| tst.js:2:20:2:32 | Math.random() | tst.js:2:20:2:32 | Math.random() | tst.js:2:20:2:32 | Math.random() | This uses a cryptographically insecure random number generated at $@ in a security context. | tst.js:2:20:2:32 | Math.random() | Math.random() |
93101
| tst.js:6:20:6:43 | "prefix ... andom() | tst.js:6:31:6:43 | Math.random() | tst.js:6:20:6:43 | "prefix ... andom() | This uses a cryptographically insecure random number generated at $@ in a security context. | tst.js:6:31:6:43 | Math.random() | Math.random() |
94102
| tst.js:10:20:10:32 | Math.random() | tst.js:10:20:10:32 | Math.random() | tst.js:10:20:10:32 | Math.random() | This uses a cryptographically insecure random number generated at $@ in a security context. | tst.js:10:20:10:32 | Math.random() | Math.random() |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getRandom } from "./library1";
2+
import { doAuth } from "./library2";
3+
4+
function f() {
5+
doAuth(getRandom());
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function getRandom() {
2+
return Math.random();
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function doAuth(pw) {
2+
var password = pw;
3+
}

0 commit comments

Comments
 (0)