Skip to content

Commit 80a7b52

Browse files
hvitvedtamasvajk
authored andcommitted
C#: Convert data-flow test queries to path-problems
1 parent 0698bdd commit 80a7b52

File tree

5 files changed

+102
-20
lines changed

5 files changed

+102
-20
lines changed
Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
1-
| CSharp7.cs:41:13:41:21 | "tainted" | CSharp7.cs:53:18:53:19 | access to local variable t1 |
2-
| CSharp7.cs:57:11:57:19 | "tainted" | CSharp7.cs:58:18:58:19 | access to local variable t4 |
3-
| CSharp7.cs:89:19:89:27 | "tainted" | CSharp7.cs:92:18:92:28 | call to method I |
4-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:177:22:177:30 | "tainted" |
5-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:183:21:183:26 | call to local function g |
6-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:184:21:184:26 | call to local function h |
1+
edges
2+
| CSharp7.cs:41:9:41:21 | SSA def(x) : String | CSharp7.cs:51:22:51:23 | SSA def(t1) : String |
3+
| CSharp7.cs:41:13:41:21 | "tainted" : String | CSharp7.cs:41:9:41:21 | SSA def(x) : String |
4+
| CSharp7.cs:51:22:51:23 | SSA def(t1) : String | CSharp7.cs:53:18:53:19 | access to local variable t1 |
5+
| CSharp7.cs:57:11:57:19 | "tainted" : String | CSharp7.cs:57:30:57:31 | SSA def(t4) : String |
6+
| CSharp7.cs:57:30:57:31 | SSA def(t4) : String | CSharp7.cs:58:18:58:19 | access to local variable t4 |
7+
| CSharp7.cs:89:18:89:34 | (..., ...) [Item1] : String | CSharp7.cs:92:20:92:21 | access to local variable t1 [Item1] : String |
8+
| CSharp7.cs:89:19:89:27 | "tainted" : String | CSharp7.cs:89:18:89:34 | (..., ...) [Item1] : String |
9+
| CSharp7.cs:92:20:92:21 | access to local variable t1 [Item1] : String | CSharp7.cs:92:20:92:27 | access to field Item1 : String |
10+
| CSharp7.cs:92:20:92:27 | access to field Item1 : String | CSharp7.cs:92:18:92:28 | call to method I |
11+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:183:23:183:25 | access to local variable src : String |
12+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:184:23:184:25 | access to local variable src : String |
13+
| CSharp7.cs:183:23:183:25 | access to local variable src : String | CSharp7.cs:183:21:183:26 | call to local function g |
14+
| CSharp7.cs:184:23:184:25 | access to local variable src : String | CSharp7.cs:184:21:184:26 | call to local function h |
15+
nodes
16+
| CSharp7.cs:41:9:41:21 | SSA def(x) : String | semmle.label | SSA def(x) : String |
17+
| CSharp7.cs:41:13:41:21 | "tainted" : String | semmle.label | "tainted" : String |
18+
| CSharp7.cs:51:22:51:23 | SSA def(t1) : String | semmle.label | SSA def(t1) : String |
19+
| CSharp7.cs:53:18:53:19 | access to local variable t1 | semmle.label | access to local variable t1 |
20+
| CSharp7.cs:57:11:57:19 | "tainted" : String | semmle.label | "tainted" : String |
21+
| CSharp7.cs:57:30:57:31 | SSA def(t4) : String | semmle.label | SSA def(t4) : String |
22+
| CSharp7.cs:58:18:58:19 | access to local variable t4 | semmle.label | access to local variable t4 |
23+
| CSharp7.cs:89:18:89:34 | (..., ...) [Item1] : String | semmle.label | (..., ...) [Item1] : String |
24+
| CSharp7.cs:89:19:89:27 | "tainted" : String | semmle.label | "tainted" : String |
25+
| CSharp7.cs:92:18:92:28 | call to method I | semmle.label | call to method I |
26+
| CSharp7.cs:92:20:92:21 | access to local variable t1 [Item1] : String | semmle.label | access to local variable t1 [Item1] : String |
27+
| CSharp7.cs:92:20:92:27 | access to field Item1 : String | semmle.label | access to field Item1 : String |
28+
| CSharp7.cs:177:22:177:30 | "tainted" | semmle.label | "tainted" |
29+
| CSharp7.cs:177:22:177:30 | "tainted" : String | semmle.label | "tainted" : String |
30+
| CSharp7.cs:183:21:183:26 | call to local function g | semmle.label | call to local function g |
31+
| CSharp7.cs:183:23:183:25 | access to local variable src : String | semmle.label | access to local variable src : String |
32+
| CSharp7.cs:184:21:184:26 | call to local function h | semmle.label | call to local function h |
33+
| CSharp7.cs:184:23:184:25 | access to local variable src : String | semmle.label | access to local variable src : String |
34+
#select
35+
| CSharp7.cs:41:13:41:21 | "tainted" : String | CSharp7.cs:41:13:41:21 | "tainted" : String | CSharp7.cs:53:18:53:19 | access to local variable t1 | $@ | CSharp7.cs:53:18:53:19 | access to local variable t1 | access to local variable t1 |
36+
| CSharp7.cs:57:11:57:19 | "tainted" : String | CSharp7.cs:57:11:57:19 | "tainted" : String | CSharp7.cs:58:18:58:19 | access to local variable t4 | $@ | CSharp7.cs:58:18:58:19 | access to local variable t4 | access to local variable t4 |
37+
| CSharp7.cs:89:19:89:27 | "tainted" : String | CSharp7.cs:89:19:89:27 | "tainted" : String | CSharp7.cs:92:18:92:28 | call to method I | $@ | CSharp7.cs:92:18:92:28 | call to method I | call to method I |
38+
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:177:22:177:30 | "tainted" | $@ | CSharp7.cs:177:22:177:30 | "tainted" | "tainted" |
39+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:183:21:183:26 | call to local function g | $@ | CSharp7.cs:183:21:183:26 | call to local function g | call to local function g |
40+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:184:21:184:26 | call to local function h | $@ | CSharp7.cs:184:21:184:26 | call to local function h | call to local function h |

csharp/ql/test/library-tests/csharp7/GlobalFlow.ql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
15
import csharp
6+
import DataFlow::PathGraph
27

38
class DataflowConfiguration extends DataFlow::Configuration {
49
DataflowConfiguration() { this = "data flow configuration" }
@@ -12,6 +17,6 @@ class DataflowConfiguration extends DataFlow::Configuration {
1217
}
1318
}
1419

15-
from DataflowConfiguration config, DataFlow::Node source, DataFlow::Node sink
16-
where config.hasFlow(source, sink)
17-
select source, sink
20+
from DataFlow::PathNode source, DataFlow::PathNode sink, DataflowConfiguration conf
21+
where conf.hasFlowPath(source, sink)
22+
select source, source, sink, "$@", sink, sink.toString()
Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
1-
| CSharp7.cs:41:13:41:21 | "tainted" | CSharp7.cs:53:18:53:19 | access to local variable t1 |
2-
| CSharp7.cs:57:11:57:19 | "tainted" | CSharp7.cs:58:18:58:19 | access to local variable t4 |
3-
| CSharp7.cs:89:19:89:27 | "tainted" | CSharp7.cs:92:18:92:28 | call to method I |
4-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:177:22:177:30 | "tainted" |
5-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:182:21:182:26 | call to local function f |
6-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:183:21:183:26 | call to local function g |
7-
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:184:21:184:26 | call to local function h |
1+
edges
2+
| CSharp7.cs:41:9:41:21 | SSA def(x) : String | CSharp7.cs:51:22:51:23 | SSA def(t1) : String |
3+
| CSharp7.cs:41:13:41:21 | "tainted" : String | CSharp7.cs:41:9:41:21 | SSA def(x) : String |
4+
| CSharp7.cs:51:22:51:23 | SSA def(t1) : String | CSharp7.cs:53:18:53:19 | access to local variable t1 |
5+
| CSharp7.cs:57:11:57:19 | "tainted" : String | CSharp7.cs:57:30:57:31 | SSA def(t4) : String |
6+
| CSharp7.cs:57:30:57:31 | SSA def(t4) : String | CSharp7.cs:58:18:58:19 | access to local variable t4 |
7+
| CSharp7.cs:89:18:89:34 | (..., ...) [Item1] : String | CSharp7.cs:92:20:92:21 | access to local variable t1 [Item1] : String |
8+
| CSharp7.cs:89:19:89:27 | "tainted" : String | CSharp7.cs:89:18:89:34 | (..., ...) [Item1] : String |
9+
| CSharp7.cs:92:20:92:21 | access to local variable t1 [Item1] : String | CSharp7.cs:92:20:92:27 | access to field Item1 : String |
10+
| CSharp7.cs:92:20:92:27 | access to field Item1 : String | CSharp7.cs:92:18:92:28 | call to method I |
11+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:182:23:182:25 | access to local variable src : String |
12+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:183:23:183:25 | access to local variable src : String |
13+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:184:23:184:25 | access to local variable src : String |
14+
| CSharp7.cs:182:23:182:25 | access to local variable src : String | CSharp7.cs:182:21:182:26 | call to local function f |
15+
| CSharp7.cs:183:23:183:25 | access to local variable src : String | CSharp7.cs:183:21:183:26 | call to local function g |
16+
| CSharp7.cs:184:23:184:25 | access to local variable src : String | CSharp7.cs:184:21:184:26 | call to local function h |
17+
nodes
18+
| CSharp7.cs:41:9:41:21 | SSA def(x) : String | semmle.label | SSA def(x) : String |
19+
| CSharp7.cs:41:13:41:21 | "tainted" : String | semmle.label | "tainted" : String |
20+
| CSharp7.cs:51:22:51:23 | SSA def(t1) : String | semmle.label | SSA def(t1) : String |
21+
| CSharp7.cs:53:18:53:19 | access to local variable t1 | semmle.label | access to local variable t1 |
22+
| CSharp7.cs:57:11:57:19 | "tainted" : String | semmle.label | "tainted" : String |
23+
| CSharp7.cs:57:30:57:31 | SSA def(t4) : String | semmle.label | SSA def(t4) : String |
24+
| CSharp7.cs:58:18:58:19 | access to local variable t4 | semmle.label | access to local variable t4 |
25+
| CSharp7.cs:89:18:89:34 | (..., ...) [Item1] : String | semmle.label | (..., ...) [Item1] : String |
26+
| CSharp7.cs:89:19:89:27 | "tainted" : String | semmle.label | "tainted" : String |
27+
| CSharp7.cs:92:18:92:28 | call to method I | semmle.label | call to method I |
28+
| CSharp7.cs:92:20:92:21 | access to local variable t1 [Item1] : String | semmle.label | access to local variable t1 [Item1] : String |
29+
| CSharp7.cs:92:20:92:27 | access to field Item1 : String | semmle.label | access to field Item1 : String |
30+
| CSharp7.cs:177:22:177:30 | "tainted" | semmle.label | "tainted" |
31+
| CSharp7.cs:177:22:177:30 | "tainted" : String | semmle.label | "tainted" : String |
32+
| CSharp7.cs:182:21:182:26 | call to local function f | semmle.label | call to local function f |
33+
| CSharp7.cs:182:23:182:25 | access to local variable src : String | semmle.label | access to local variable src : String |
34+
| CSharp7.cs:183:21:183:26 | call to local function g | semmle.label | call to local function g |
35+
| CSharp7.cs:183:23:183:25 | access to local variable src : String | semmle.label | access to local variable src : String |
36+
| CSharp7.cs:184:21:184:26 | call to local function h | semmle.label | call to local function h |
37+
| CSharp7.cs:184:23:184:25 | access to local variable src : String | semmle.label | access to local variable src : String |
38+
#select
39+
| CSharp7.cs:41:13:41:21 | "tainted" : String | CSharp7.cs:41:13:41:21 | "tainted" : String | CSharp7.cs:53:18:53:19 | access to local variable t1 | $@ | CSharp7.cs:53:18:53:19 | access to local variable t1 | access to local variable t1 |
40+
| CSharp7.cs:57:11:57:19 | "tainted" : String | CSharp7.cs:57:11:57:19 | "tainted" : String | CSharp7.cs:58:18:58:19 | access to local variable t4 | $@ | CSharp7.cs:58:18:58:19 | access to local variable t4 | access to local variable t4 |
41+
| CSharp7.cs:89:19:89:27 | "tainted" : String | CSharp7.cs:89:19:89:27 | "tainted" : String | CSharp7.cs:92:18:92:28 | call to method I | $@ | CSharp7.cs:92:18:92:28 | call to method I | call to method I |
42+
| CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:177:22:177:30 | "tainted" | CSharp7.cs:177:22:177:30 | "tainted" | $@ | CSharp7.cs:177:22:177:30 | "tainted" | "tainted" |
43+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:182:21:182:26 | call to local function f | $@ | CSharp7.cs:182:21:182:26 | call to local function f | call to local function f |
44+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:183:21:183:26 | call to local function g | $@ | CSharp7.cs:183:21:183:26 | call to local function g | call to local function g |
45+
| CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:177:22:177:30 | "tainted" : String | CSharp7.cs:184:21:184:26 | call to local function h | $@ | CSharp7.cs:184:21:184:26 | call to local function h | call to local function h |

csharp/ql/test/library-tests/csharp7/GlobalTaintTracking.ql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
15
import csharp
6+
import DataFlow::PathGraph
27

38
class DataflowConfiguration extends TaintTracking::Configuration {
49
DataflowConfiguration() { this = "taint tracking configuration" }
@@ -12,6 +17,6 @@ class DataflowConfiguration extends TaintTracking::Configuration {
1217
}
1318
}
1419

15-
from DataflowConfiguration config, DataFlow::Node source, DataFlow::Node sink
16-
where config.hasFlow(source, sink)
17-
select source, sink
20+
from DataFlow::PathNode source, DataFlow::PathNode sink, DataflowConfiguration conf
21+
where conf.hasFlowPath(source, sink)
22+
select source, source, sink, "$@", sink, sink.toString()

csharp/ql/test/library-tests/dataflow/tuples/Tuples.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import csharp
66
import DataFlow::PathGraph
77

88
class Conf extends DataFlow::Configuration {
9-
Conf() { this = "TypesConf" }
9+
Conf() { this = "TuplesConf" }
1010

1111
override predicate isSource(DataFlow::Node src) {
1212
src.asExpr().(StringLiteral).getValue() = "taint source"

0 commit comments

Comments
 (0)