JS: Update Generators test

Data flow difference is benign
This commit is contained in:
Asger F
2023-10-06 10:02:04 +02:00
parent 995df41532
commit 9372f7993d
3 changed files with 46 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
legacyDataFlowDifference
| generators.js:2:16:2:23 | "source" | generators.js:37:10:37:10 | e | only flow with OLD data flow library |
| generators.js:2:16:2:23 | "source" | generators.js:46:10:46:10 | e | only flow with NEW data flow library |
| generators.js:2:16:2:23 | "source" | generators.js:51:10:51:10 | e | only flow with NEW data flow library |
consistencyIssue

View File

@@ -1,12 +1,28 @@
import javascript
import testUtilities.ConsistencyChecking
class GeneratorFlowConfig extends DataFlow::Configuration {
GeneratorFlowConfig() { this = "GeneratorFlowConfig" }
module TestConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
override predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
sink = any(DataFlow::CallNode call | call.getCalleeName() = "sink").getAnArgument()
}
}
module TestFlow = DataFlow::Global<TestConfig>;
class LegacyConfig extends DataFlow::Configuration {
LegacyConfig() { this = "GeneratorFlowConfig" }
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
}
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
class Consistency extends ConsistencyConfiguration {
Consistency() { this = "Consistency" }
override DataFlow::Node getAnAlert() { TestFlow::flowTo(result) }
}

View File

@@ -31,6 +31,26 @@
sink(e); // NOT OK
}
try {
gen4();
} catch (e) {
sink(e); // OK - exception is only thrown upon iteration
}
const iterator = gen4();
try {
for (let v of iterator) {
sink(v); // OK
}
} catch (e) {
sink(e); // NOT OK
}
try {
Array.from(iterator);
} catch (e) {
sink(e); // NOT OK
}
function *delegating() {
yield* delegate();
}