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

Skip to content

Commit 081ee99

Browse files
committed
C#: Add more copies of the data flow library
1 parent d0a7614 commit 081ee99

11 files changed

Lines changed: 7715 additions & 3 deletions

File tree

config/identical-files.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"DataFlow Java/C++": [
2+
"DataFlow Java/C++/C#": [
33
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll",
44
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll",
55
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll",
@@ -13,9 +13,13 @@
1313
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll",
1414
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll",
1515
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll",
16-
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll"
16+
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll",
17+
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll",
18+
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll",
19+
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll",
20+
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll"
1721
],
18-
"DataFlow Java/C++ Common": [
22+
"DataFlow Java/C++/C# Common": [
1923
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll",
2024
"cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll",
2125
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImplCommon.qll",

csharp/ql/src/semmle/code/csharp/dataflow/DataFlow.qll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,23 @@ import csharp
77

88
module DataFlow {
99
import semmle.code.csharp.dataflow.internal.DataFlowImpl
10+
11+
/**
12+
* This class exists to prevent mutual recursion between the user-overridden
13+
* member predicates of `Configuration` and the rest of the data-flow library.
14+
* Good performance cannot be guaranteed in the presence of such recursion, so
15+
* it should be replaced by using more than one copy of the data flow library.
16+
* Four copies are available: `DataFlow` through `DataFlow4`.
17+
*/
18+
abstract private class ConfigurationRecursionPrevention extends Configuration {
19+
bindingset[this]
20+
ConfigurationRecursionPrevention() { any() }
21+
22+
override predicate hasFlow(Node source, Node sink) {
23+
strictcount(Node n | this.isSource(n)) < 0 or
24+
strictcount(Node n | this.isSink(n)) < 0 or
25+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or
26+
super.hasFlow(source, sink)
27+
}
28+
}
1029
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Provides classes for performing local (intra-procedural) and
3+
* global (inter-procedural) data flow analyses.
4+
*/
5+
6+
import csharp
7+
8+
module DataFlow2 {
9+
import semmle.code.csharp.dataflow.internal.DataFlowImpl2
10+
11+
/**
12+
* This class exists to prevent mutual recursion between the user-overridden
13+
* member predicates of `Configuration` and the rest of the data-flow library.
14+
* Good performance cannot be guaranteed in the presence of such recursion, so
15+
* it should be replaced by using more than one copy of the data flow library.
16+
* Four copies are available: `DataFlow` through `DataFlow4`.
17+
*/
18+
abstract private class ConfigurationRecursionPrevention extends Configuration {
19+
bindingset[this]
20+
ConfigurationRecursionPrevention() { any() }
21+
22+
override predicate hasFlow(Node source, Node sink) {
23+
strictcount(Node n | this.isSource(n)) < 0 or
24+
strictcount(Node n | this.isSink(n)) < 0 or
25+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or
26+
super.hasFlow(source, sink)
27+
}
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Provides classes for performing local (intra-procedural) and
3+
* global (inter-procedural) data flow analyses.
4+
*/
5+
6+
import csharp
7+
8+
module DataFlow3 {
9+
import semmle.code.csharp.dataflow.internal.DataFlowImpl3
10+
11+
/**
12+
* This class exists to prevent mutual recursion between the user-overridden
13+
* member predicates of `Configuration` and the rest of the data-flow library.
14+
* Good performance cannot be guaranteed in the presence of such recursion, so
15+
* it should be replaced by using more than one copy of the data flow library.
16+
* Four copies are available: `DataFlow` through `DataFlow4`.
17+
*/
18+
abstract private class ConfigurationRecursionPrevention extends Configuration {
19+
bindingset[this]
20+
ConfigurationRecursionPrevention() { any() }
21+
22+
override predicate hasFlow(Node source, Node sink) {
23+
strictcount(Node n | this.isSource(n)) < 0 or
24+
strictcount(Node n | this.isSink(n)) < 0 or
25+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or
26+
super.hasFlow(source, sink)
27+
}
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Provides classes for performing local (intra-procedural) and
3+
* global (inter-procedural) data flow analyses.
4+
*/
5+
6+
import csharp
7+
8+
module DataFlow4 {
9+
import semmle.code.csharp.dataflow.internal.DataFlowImpl4
10+
11+
/**
12+
* This class exists to prevent mutual recursion between the user-overridden
13+
* member predicates of `Configuration` and the rest of the data-flow library.
14+
* Good performance cannot be guaranteed in the presence of such recursion, so
15+
* it should be replaced by using more than one copy of the data flow library.
16+
* Four copies are available: `DataFlow` through `DataFlow4`.
17+
*/
18+
abstract private class ConfigurationRecursionPrevention extends Configuration {
19+
bindingset[this]
20+
ConfigurationRecursionPrevention() { any() }
21+
22+
override predicate hasFlow(Node source, Node sink) {
23+
strictcount(Node n | this.isSource(n)) < 0 or
24+
strictcount(Node n | this.isSink(n)) < 0 or
25+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or
26+
super.hasFlow(source, sink)
27+
}
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Provides classes for performing local (intra-procedural) and
3+
* global (inter-procedural) data flow analyses.
4+
*/
5+
6+
import csharp
7+
8+
module DataFlow5 {
9+
import semmle.code.csharp.dataflow.internal.DataFlowImpl5
10+
11+
/**
12+
* This class exists to prevent mutual recursion between the user-overridden
13+
* member predicates of `Configuration` and the rest of the data-flow library.
14+
* Good performance cannot be guaranteed in the presence of such recursion, so
15+
* it should be replaced by using more than one copy of the data flow library.
16+
* Four copies are available: `DataFlow` through `DataFlow4`.
17+
*/
18+
abstract private class ConfigurationRecursionPrevention extends Configuration {
19+
bindingset[this]
20+
ConfigurationRecursionPrevention() { any() }
21+
22+
override predicate hasFlow(Node source, Node sink) {
23+
strictcount(Node n | this.isSource(n)) < 0 or
24+
strictcount(Node n | this.isSink(n)) < 0 or
25+
strictcount(Node n1, Node n2 | this.isAdditionalFlowStep(n1, n2)) < 0 or
26+
super.hasFlow(source, sink)
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)