Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff08637

Browse files
committed
JS: Port Arrays test
1 parent d35959a commit ff08637

4 files changed

Lines changed: 36 additions & 16 deletions

File tree

javascript/ql/test/library-tests/Arrays/DataFlow.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
legacyDataFlowDifference
2+
flow
13
| arrays.js:2:16:2:23 | "source" | arrays.js:5:8:5:14 | obj.foo |
24
| arrays.js:2:16:2:23 | "source" | arrays.js:11:10:11:15 | arr[i] |
35
| arrays.js:2:16:2:23 | "source" | arrays.js:15:27:15:27 | e |
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import javascript
22

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

6-
override predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
7-
8-
override predicate isSink(DataFlow::Node sink) {
6+
predicate isSink(DataFlow::Node sink) {
97
sink = any(DataFlow::CallNode call | call.getCalleeName() = "sink").getAnArgument()
108
}
119
}
1210

13-
from ArrayFlowConfig config, DataFlow::Node src, DataFlow::Node snk
14-
where config.hasFlow(src, snk)
15-
select src, snk
11+
module TestFlow = DataFlow::Global<TestConfig>;
12+
13+
class LegacyConfig extends DataFlow::Configuration {
14+
LegacyConfig() { this = "LegacyConfig" }
15+
16+
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
17+
18+
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
19+
}
20+
21+
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
22+
23+
query predicate flow = TestFlow::flow/2;

javascript/ql/test/library-tests/Arrays/TaintFlow.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
legacyDataFlowDifference
2+
flow
13
| arrays.js:2:16:2:23 | "source" | arrays.js:5:8:5:14 | obj.foo |
24
| arrays.js:2:16:2:23 | "source" | arrays.js:11:10:11:15 | arr[i] |
35
| arrays.js:2:16:2:23 | "source" | arrays.js:15:27:15:27 | e |
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import javascript
22

3-
class ArrayTaintFlowConfig extends TaintTracking::Configuration {
4-
ArrayTaintFlowConfig() { this = "ArrayTaintFlowConfig" }
3+
module TestConfig implements DataFlow::ConfigSig {
4+
predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
55

6-
override predicate isSource(DataFlow::Node source) { source.asExpr().getStringValue() = "source" }
7-
8-
override predicate isSink(DataFlow::Node sink) {
6+
predicate isSink(DataFlow::Node sink) {
97
sink = any(DataFlow::CallNode call | call.getCalleeName() = "sink").getAnArgument()
108
}
119
}
1210

13-
from ArrayTaintFlowConfig config, DataFlow::Node src, DataFlow::Node snk
14-
where config.hasFlow(src, snk)
15-
select src, snk
11+
module TestFlow = TaintTracking::Global<TestConfig>;
12+
13+
class LegacyConfig extends TaintTracking::Configuration {
14+
LegacyConfig() { this = "LegacyConfig" }
15+
16+
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
17+
18+
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
19+
}
20+
21+
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
22+
23+
query predicate flow = TestFlow::flow/2;

0 commit comments

Comments
 (0)