mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
JS: Update Generators test
Data flow difference is benign
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user