Skip to content

Commit 9a15a55

Browse files
committed
JS: Port SimpleBarrierGuard test
1 parent ff08637 commit 9a15a55

2 files changed

Lines changed: 30 additions & 14 deletions

File tree

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
| tst.js:4:10:4:10 | x | tst.js:2:13:2:20 | SOURCE() |
2-
| tst.js:9:14:9:14 | x | tst.js:2:13:2:20 | SOURCE() |
3-
| tst.js:12:10:12:10 | x | tst.js:2:13:2:20 | SOURCE() |
1+
legacyDataFlowDifference
2+
flow
3+
| tst.js:2:13:2:20 | SOURCE() | tst.js:4:10:4:10 | x |
4+
| tst.js:2:13:2:20 | SOURCE() | tst.js:9:14:9:14 | x |
5+
| tst.js:2:13:2:20 | SOURCE() | tst.js:12:10:12:10 | x |
Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
import javascript
22

3-
class Configuration extends DataFlow::Configuration {
4-
Configuration() { this = "SimpleBarrierGuard" }
5-
6-
override predicate isSource(DataFlow::Node source) {
3+
module TestConfig implements DataFlow::ConfigSig {
4+
predicate isSource(DataFlow::Node source) {
75
source.(DataFlow::InvokeNode).getCalleeName() = "SOURCE"
86
}
97

10-
override predicate isSink(DataFlow::Node sink) {
8+
predicate isSink(DataFlow::Node sink) {
119
exists(DataFlow::InvokeNode call |
1210
call.getCalleeName() = "SINK" and
1311
sink = call.getArgument(0)
1412
)
1513
}
1614

17-
override predicate isBarrierGuard(DataFlow::BarrierGuardNode guard) {
18-
guard instanceof SimpleBarrierGuardNode
15+
predicate isBarrier(DataFlow::Node node) {
16+
node = DataFlow::MakeBarrierGuard<SimpleBarrierGuardNode>::getABarrierNode()
1917
}
2018
}
2119

20+
module TestFlow = DataFlow::Global<TestConfig>;
21+
2222
class SimpleBarrierGuardNode extends DataFlow::BarrierGuardNode, DataFlow::InvokeNode {
2323
SimpleBarrierGuardNode() { this.getCalleeName() = "BARRIER" }
2424

25-
override predicate blocks(boolean outcome, Expr e) {
25+
override predicate blocks(boolean outcome, Expr e) { this.blocksExpr(outcome, e) }
26+
27+
predicate blocksExpr(boolean outcome, Expr e) {
2628
outcome = true and
2729
e = this.getArgument(0).asExpr()
2830
}
2931
}
3032

31-
from Configuration cfg, DataFlow::Node source, DataFlow::Node sink
32-
where cfg.hasFlow(source, sink)
33-
select sink, source
33+
class LegacyConfig extends DataFlow::Configuration {
34+
LegacyConfig() { this = "LegacyConfig" }
35+
36+
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
37+
38+
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
39+
40+
override predicate isBarrierGuard(DataFlow::BarrierGuardNode guard) {
41+
guard instanceof SimpleBarrierGuardNode
42+
}
43+
}
44+
45+
import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>
46+
47+
query predicate flow = TestFlow::flow/2;

0 commit comments

Comments
 (0)