|
1 | 1 | import javascript |
2 | 2 |
|
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) { |
7 | 5 | source.(DataFlow::InvokeNode).getCalleeName() = "SOURCE" |
8 | 6 | } |
9 | 7 |
|
10 | | - override predicate isSink(DataFlow::Node sink) { |
| 8 | + predicate isSink(DataFlow::Node sink) { |
11 | 9 | exists(DataFlow::InvokeNode call | |
12 | 10 | call.getCalleeName() = "SINK" and |
13 | 11 | sink = call.getArgument(0) |
14 | 12 | ) |
15 | 13 | } |
16 | 14 |
|
17 | | - override predicate isBarrierGuard(DataFlow::BarrierGuardNode guard) { |
18 | | - guard instanceof SimpleBarrierGuardNode |
| 15 | + predicate isBarrier(DataFlow::Node node) { |
| 16 | + node = DataFlow::MakeBarrierGuard<SimpleBarrierGuardNode>::getABarrierNode() |
19 | 17 | } |
20 | 18 | } |
21 | 19 |
|
| 20 | +module TestFlow = DataFlow::Global<TestConfig>; |
| 21 | + |
22 | 22 | class SimpleBarrierGuardNode extends DataFlow::BarrierGuardNode, DataFlow::InvokeNode { |
23 | 23 | SimpleBarrierGuardNode() { this.getCalleeName() = "BARRIER" } |
24 | 24 |
|
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) { |
26 | 28 | outcome = true and |
27 | 29 | e = this.getArgument(0).asExpr() |
28 | 30 | } |
29 | 31 | } |
30 | 32 |
|
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