Skip to content

Commit afcd15e

Browse files
committed
JS: Update Generators test
Data flow difference is benign
1 parent 0ee0c75 commit afcd15e

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
legacyDataFlowDifference
2+
| generators.js:2:16:2:23 | "source" | generators.js:37:10:37:10 | e | only flow with OLD data flow library |
3+
| generators.js:2:16:2:23 | "source" | generators.js:46:10:46:10 | e | only flow with NEW data flow library |
4+
| generators.js:2:16:2:23 | "source" | generators.js:51:10:51:10 | e | only flow with NEW data flow library |
5+
consistencyIssue
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
import javascript
22
import testUtilities.ConsistencyChecking
33

4-
class GeneratorFlowConfig extends DataFlow::Configuration {
5-
GeneratorFlowConfig() { this = "GeneratorFlowConfig" }
4+
module TestConfig implements DataFlow::ConfigSig {
5+
predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
66

7-
override predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
8-
9-
override predicate isSink(DataFlow::Node sink) {
7+
predicate isSink(DataFlow::Node sink) {
108
sink = any(DataFlow::CallNode call | call.getCalleeName() = "sink").getAnArgument()
119
}
1210
}
11+
12+
module TestFlow = DataFlow::Global<TestConfig>;
13+
14+
class LegacyConfig extends DataFlow::Configuration {
15+
LegacyConfig() { this = "GeneratorFlowConfig" }
16+
17+
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
18+
19+
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
20+
}
21+
22+
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
23+
24+
class Consistency extends ConsistencyConfiguration {
25+
Consistency() { this = "Consistency" }
26+
27+
override DataFlow::Node getAnAlert() { TestFlow::flowTo(result) }
28+
}

javascript/ql/test/library-tests/Generators/generators.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@
3131
sink(e); // NOT OK
3232
}
3333

34+
try {
35+
gen4();
36+
} catch (e) {
37+
sink(e); // OK - exception is only thrown upon iteration
38+
}
39+
40+
const iterator = gen4();
41+
try {
42+
for (let v of iterator) {
43+
sink(v); // OK
44+
}
45+
} catch (e) {
46+
sink(e); // NOT OK
47+
}
48+
try {
49+
Array.from(iterator);
50+
} catch (e) {
51+
sink(e); // NOT OK
52+
}
53+
3454
function *delegating() {
3555
yield* delegate();
3656
}

0 commit comments

Comments
 (0)