Skip to content

Commit 7f2eae0

Browse files
committed
JS: Add test case for false flow through IIFEs
We generate local flow steps into and out of IIFEs, but these come jump steps automatically, resulting in FPs.
1 parent 7acc568 commit 7f2eae0

File tree

1 file changed

+43
-0
lines changed
  • javascript/ql/test/library-tests/TripleDot

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function f1() {
2+
function inner(x) {
3+
return (function(p) {
4+
return p; // argument to return
5+
})(x);
6+
}
7+
sink(inner(source("f1.1"))); // $ hasValueFlow=f1.1 SPURIOUS: hasValueFlow=f1.2
8+
sink(inner(source("f1.2"))); // $ hasValueFlow=f1.2 SPURIOUS: hasValueFlow=f1.1
9+
}
10+
11+
function f2() {
12+
function inner(x) {
13+
let y;
14+
(function(p) {
15+
y = p; // parameter to captured variable
16+
})(x);
17+
return y;
18+
}
19+
sink(inner(source("f2.1"))); // $ hasValueFlow=f2.1 SPURIOUS: hasValueFlow=f2.2
20+
sink(inner(source("f2.2"))); // $ hasValueFlow=f2.2 SPURIOUS: hasValueFlow=f2.1
21+
}
22+
23+
function f3() {
24+
function inner(x) {
25+
return (function() {
26+
return x; // captured variable to return
27+
})();
28+
}
29+
sink(inner(source("f3.1"))); // $ hasValueFlow=f3.1 SPURIOUS: hasValueFlow=f3.2
30+
sink(inner(source("f3.2"))); // $ hasValueFlow=f3.2 SPURIOUS: hasValueFlow=f3.1
31+
}
32+
33+
function f4() {
34+
function inner(x) {
35+
let y;
36+
(function() {
37+
y = x; // captured variable to captured variable
38+
})();
39+
return y;
40+
}
41+
sink(inner(source("f4.1"))); // $ hasValueFlow=f4.1
42+
sink(inner(source("f4.2"))); // $ hasValueFlow=f4.2
43+
}

0 commit comments

Comments
 (0)