JS: Port ComposedFunctions test

This commit is contained in:
Asger F
2023-10-05 21:01:44 +02:00
parent 09892279e6
commit 6600fe9d51
2 changed files with 19 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
legacyDataFlowDifference
#select
| tst.js:10:10:10:15 | source |
| tst.js:15:10:15:13 | f1() |
| tst.js:20:10:20:24 | lcompose1(f2)() |

View File

@@ -1,13 +1,11 @@
import javascript
class ExampleConfiguration extends TaintTracking::Configuration {
ExampleConfiguration() { this = "ExampleConfiguration" }
override predicate isSource(DataFlow::Node source) {
module TestConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr().(CallExpr).getCalleeName() = "SOURCE"
}
override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
exists(CallExpr callExpr |
callExpr.getCalleeName() = "SINK" and
DataFlow::valueNode(callExpr.getArgument(0)) = sink
@@ -15,6 +13,18 @@ class ExampleConfiguration extends TaintTracking::Configuration {
}
}
from ExampleConfiguration cfg, DataFlow::Node source, DataFlow::Node sink
where cfg.hasFlow(source, sink)
module TestFlow = TaintTracking::Global<TestConfig>;
class LegacyConfig extends TaintTracking::Configuration {
LegacyConfig() { this = "LegacyConfig" }
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
}
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
from DataFlow::Node source, DataFlow::Node sink
where TestFlow::flow(source, sink)
select sink