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

Skip to content

Commit fdd3b90

Browse files
committed
C/C#/Java: Share ConfigurationRecursionPrevention
This class was copy-pasted in all `DataFlowN.qll` files without using the identical-files system to keep the copies in sync. The class is now moved to the `DataFlowImplN.qll` files. This also has the effect of preventing recursion through first data flow library copy for C/C++. Such recursion has been deprecated for over a year, and some forms of recursions are already ruled out by the library implementation.
1 parent c2d1a52 commit fdd3b90

34 files changed

Lines changed: 396 additions & 328 deletions

cpp/ql/src/semmle/code/cpp/dataflow/DataFlow2.qll

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,4 @@ import cpp
1212

1313
module DataFlow2 {
1414
import semmle.code.cpp.dataflow.internal.DataFlowImpl2
15-
16-
/**
17-
* This class exists to prevent mutual recursion between the user-overridden
18-
* member predicates of `Configuration` and the rest of the data-flow library.
19-
* Good performance cannot be guaranteed in the presence of such recursion, so
20-
* it should be replaced by using more than one copy of the data flow library.
21-
* Four copies are available: `DataFlow` through `DataFlow4`.
22-
*/
23-
private abstract
24-
class ConfigurationRecursionPrevention extends Configuration {
25-
bindingset[this]
26-
ConfigurationRecursionPrevention() { any() }
27-
28-
override predicate hasFlow(Node source, Node sink) {
29-
strictcount(Node n | this.isSource(n)) < 0
30-
or
31-
strictcount(Node n | this.isSink(n)) < 0
32-
or
33-
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
34-
or
35-
super.hasFlow(source, sink)
36-
}
37-
}
3815
}

cpp/ql/src/semmle/code/cpp/dataflow/DataFlow3.qll

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,4 @@ import cpp
1212

1313
module DataFlow3 {
1414
import semmle.code.cpp.dataflow.internal.DataFlowImpl3
15-
16-
/**
17-
* This class exists to prevent mutual recursion between the user-overridden
18-
* member predicates of `Configuration` and the rest of the data-flow library.
19-
* Good performance cannot be guaranteed in the presence of such recursion, so
20-
* it should be replaced by using more than one copy of the data flow library.
21-
* Four copies are available: `DataFlow` through `DataFlow4`.
22-
*/
23-
private abstract
24-
class ConfigurationRecursionPrevention extends Configuration {
25-
bindingset[this]
26-
ConfigurationRecursionPrevention() { any() }
27-
28-
override predicate hasFlow(Node source, Node sink) {
29-
strictcount(Node n | this.isSource(n)) < 0
30-
or
31-
strictcount(Node n | this.isSink(n)) < 0
32-
or
33-
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
34-
or
35-
super.hasFlow(source, sink)
36-
}
37-
}
3815
}

cpp/ql/src/semmle/code/cpp/dataflow/DataFlow4.qll

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,4 @@ import cpp
1212

1313
module DataFlow4 {
1414
import semmle.code.cpp.dataflow.internal.DataFlowImpl4
15-
16-
/**
17-
* This class exists to prevent mutual recursion between the user-overridden
18-
* member predicates of `Configuration` and the rest of the data-flow library.
19-
* Good performance cannot be guaranteed in the presence of such recursion, so
20-
* it should be replaced by using more than one copy of the data flow library.
21-
* Four copies are available: `DataFlow` through `DataFlow4`.
22-
*/
23-
private abstract
24-
class ConfigurationRecursionPrevention extends Configuration {
25-
bindingset[this]
26-
ConfigurationRecursionPrevention() { any() }
27-
28-
override predicate hasFlow(Node source, Node sink) {
29-
strictcount(Node n | this.isSource(n)) < 0
30-
or
31-
strictcount(Node n | this.isSink(n)) < 0
32-
or
33-
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
34-
or
35-
super.hasFlow(source, sink)
36-
}
37-
}
3815
}

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,28 @@ abstract class Configuration extends string {
121121
deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) }
122122
}
123123

124+
/**
125+
* This class exists to prevent mutual recursion between the user-overridden
126+
* member predicates of `Configuration` and the rest of the data-flow library.
127+
* Good performance cannot be guaranteed in the presence of such recursion, so
128+
* it should be replaced by using more than one copy of the data flow library.
129+
*/
130+
private abstract
131+
class ConfigurationRecursionPrevention extends Configuration {
132+
bindingset[this]
133+
ConfigurationRecursionPrevention() { any() }
134+
135+
override predicate hasFlow(Node source, Node sink) {
136+
strictcount(Node n | this.isSource(n)) < 0
137+
or
138+
strictcount(Node n | this.isSink(n)) < 0
139+
or
140+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
141+
or
142+
super.hasFlow(source, sink)
143+
}
144+
}
145+
124146
private predicate inBarrier(Node node, Configuration config) {
125147
config.isBarrierIn(node) and
126148
config.isSource(node)

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,28 @@ abstract class Configuration extends string {
121121
deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) }
122122
}
123123

124+
/**
125+
* This class exists to prevent mutual recursion between the user-overridden
126+
* member predicates of `Configuration` and the rest of the data-flow library.
127+
* Good performance cannot be guaranteed in the presence of such recursion, so
128+
* it should be replaced by using more than one copy of the data flow library.
129+
*/
130+
private abstract
131+
class ConfigurationRecursionPrevention extends Configuration {
132+
bindingset[this]
133+
ConfigurationRecursionPrevention() { any() }
134+
135+
override predicate hasFlow(Node source, Node sink) {
136+
strictcount(Node n | this.isSource(n)) < 0
137+
or
138+
strictcount(Node n | this.isSink(n)) < 0
139+
or
140+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
141+
or
142+
super.hasFlow(source, sink)
143+
}
144+
}
145+
124146
private predicate inBarrier(Node node, Configuration config) {
125147
config.isBarrierIn(node) and
126148
config.isSource(node)

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,28 @@ abstract class Configuration extends string {
121121
deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) }
122122
}
123123

124+
/**
125+
* This class exists to prevent mutual recursion between the user-overridden
126+
* member predicates of `Configuration` and the rest of the data-flow library.
127+
* Good performance cannot be guaranteed in the presence of such recursion, so
128+
* it should be replaced by using more than one copy of the data flow library.
129+
*/
130+
private abstract
131+
class ConfigurationRecursionPrevention extends Configuration {
132+
bindingset[this]
133+
ConfigurationRecursionPrevention() { any() }
134+
135+
override predicate hasFlow(Node source, Node sink) {
136+
strictcount(Node n | this.isSource(n)) < 0
137+
or
138+
strictcount(Node n | this.isSink(n)) < 0
139+
or
140+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
141+
or
142+
super.hasFlow(source, sink)
143+
}
144+
}
145+
124146
private predicate inBarrier(Node node, Configuration config) {
125147
config.isBarrierIn(node) and
126148
config.isSource(node)

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,28 @@ abstract class Configuration extends string {
121121
deprecated predicate hasFlowBackward(Node source, Node sink) { hasFlow(source, sink) }
122122
}
123123

124+
/**
125+
* This class exists to prevent mutual recursion between the user-overridden
126+
* member predicates of `Configuration` and the rest of the data-flow library.
127+
* Good performance cannot be guaranteed in the presence of such recursion, so
128+
* it should be replaced by using more than one copy of the data flow library.
129+
*/
130+
private abstract
131+
class ConfigurationRecursionPrevention extends Configuration {
132+
bindingset[this]
133+
ConfigurationRecursionPrevention() { any() }
134+
135+
override predicate hasFlow(Node source, Node sink) {
136+
strictcount(Node n | this.isSource(n)) < 0
137+
or
138+
strictcount(Node n | this.isSink(n)) < 0
139+
or
140+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
141+
or
142+
super.hasFlow(source, sink)
143+
}
144+
}
145+
124146
private predicate inBarrier(Node node, Configuration config) {
125147
config.isBarrierIn(node) and
126148
config.isSource(node)

cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow2.qll

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,4 @@ import cpp
1212

1313
module DataFlow2 {
1414
import semmle.code.cpp.ir.dataflow.internal.DataFlowImpl2
15-
16-
/**
17-
* This class exists to prevent mutual recursion between the user-overridden
18-
* member predicates of `Configuration` and the rest of the data-flow library.
19-
* Good performance cannot be guaranteed in the presence of such recursion, so
20-
* it should be replaced by using more than one copy of the data flow library.
21-
* Four copies are available: `DataFlow` through `DataFlow4`.
22-
*/
23-
private abstract
24-
class ConfigurationRecursionPrevention extends Configuration {
25-
bindingset[this]
26-
ConfigurationRecursionPrevention() { any() }
27-
28-
override predicate hasFlow(Node source, Node sink) {
29-
strictcount(Node n | this.isSource(n)) < 0
30-
or
31-
strictcount(Node n | this.isSink(n)) < 0
32-
or
33-
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
34-
or
35-
super.hasFlow(source, sink)
36-
}
37-
}
3815
}

cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow3.qll

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,4 @@ import cpp
1212

1313
module DataFlow3 {
1414
import semmle.code.cpp.ir.dataflow.internal.DataFlowImpl3
15-
16-
/**
17-
* This class exists to prevent mutual recursion between the user-overridden
18-
* member predicates of `Configuration` and the rest of the data-flow library.
19-
* Good performance cannot be guaranteed in the presence of such recursion, so
20-
* it should be replaced by using more than one copy of the data flow library.
21-
* Four copies are available: `DataFlow` through `DataFlow4`.
22-
*/
23-
private abstract
24-
class ConfigurationRecursionPrevention extends Configuration {
25-
bindingset[this]
26-
ConfigurationRecursionPrevention() { any() }
27-
28-
override predicate hasFlow(Node source, Node sink) {
29-
strictcount(Node n | this.isSource(n)) < 0
30-
or
31-
strictcount(Node n | this.isSink(n)) < 0
32-
or
33-
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
34-
or
35-
super.hasFlow(source, sink)
36-
}
37-
}
3815
}

cpp/ql/src/semmle/code/cpp/ir/dataflow/DataFlow4.qll

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,4 @@ import cpp
1212

1313
module DataFlow4 {
1414
import semmle.code.cpp.ir.dataflow.internal.DataFlowImpl4
15-
16-
/**
17-
* This class exists to prevent mutual recursion between the user-overridden
18-
* member predicates of `Configuration` and the rest of the data-flow library.
19-
* Good performance cannot be guaranteed in the presence of such recursion, so
20-
* it should be replaced by using more than one copy of the data flow library.
21-
* Four copies are available: `DataFlow` through `DataFlow4`.
22-
*/
23-
private abstract
24-
class ConfigurationRecursionPrevention extends Configuration {
25-
bindingset[this]
26-
ConfigurationRecursionPrevention() { any() }
27-
28-
override predicate hasFlow(Node source, Node sink) {
29-
strictcount(Node n | this.isSource(n)) < 0
30-
or
31-
strictcount(Node n | this.isSink(n)) < 0
32-
or
33-
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0
34-
or
35-
super.hasFlow(source, sink)
36-
}
37-
}
3815
}

0 commit comments

Comments
 (0)