Skip to content

Commit a2c7388

Browse files
committed
C#: Re-factor the ExternalFlow test.
1 parent bd88620 commit a2c7388

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

csharp/ql/test/library-tests/dataflow/external-models/ExternalFlow.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
invalidModelRow
12
edges
23
| ExternalFlow.cs:9:27:9:38 | object creation of type Object : Object | ExternalFlow.cs:10:29:10:32 | access to local variable arg1 : Object |
34
| ExternalFlow.cs:10:29:10:32 | access to local variable arg1 : Object | ExternalFlow.cs:10:18:10:33 | call to method StepArgRes |
@@ -162,7 +163,6 @@ nodes
162163
| ExternalFlow.cs:206:18:206:40 | call to method MixedFlowArgs | semmle.label | call to method MixedFlowArgs |
163164
| ExternalFlow.cs:206:38:206:39 | access to local variable o2 : Object | semmle.label | access to local variable o2 : Object |
164165
subpaths
165-
invalidModelRow
166166
#select
167167
| ExternalFlow.cs:10:18:10:33 | call to method StepArgRes | ExternalFlow.cs:9:27:9:38 | object creation of type Object : Object | ExternalFlow.cs:10:18:10:33 | call to method StepArgRes | $@ | ExternalFlow.cs:9:27:9:38 | object creation of type Object : Object | object creation of type Object : Object |
168168
| ExternalFlow.cs:18:18:18:24 | access to local variable argOut1 | ExternalFlow.cs:15:29:15:40 | object creation of type Object : Object | ExternalFlow.cs:18:18:18:24 | access to local variable argOut1 | $@ | ExternalFlow.cs:15:29:15:40 | object creation of type Object : Object | object creation of type Object : Object |

csharp/ql/test/library-tests/dataflow/external-models/ExternalFlow.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
*/
44

55
import csharp
6-
import DataFlow::PathGraph
76
import semmle.code.csharp.dataflow.ExternalFlow
7+
import Taint::PathGraph
88
import ModelValidation
99

10-
class Conf extends TaintTracking::Configuration {
11-
Conf() { this = "ExternalFlow" }
10+
module TaintConfig implements DataFlow::ConfigSig {
11+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ObjectCreation }
1212

13-
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ObjectCreation }
14-
15-
override predicate isSink(DataFlow::Node sink) {
13+
predicate isSink(DataFlow::Node sink) {
1614
exists(MethodCall mc |
1715
mc.getTarget().hasName("Sink") and
1816
mc.getAnArgument() = sink.asExpr()
1917
)
2018
}
2119
}
2220

21+
module Taint = TaintTracking::Global<TaintConfig>;
22+
2323
/**
2424
* Simulate that methods with summaries are not included in the source code.
2525
* This is relevant for dataflow analysis using summaries tagged as generated.
@@ -28,6 +28,6 @@ private class MyMethod extends Method {
2828
override predicate fromSource() { none() }
2929
}
3030

31-
from DataFlow::PathNode source, DataFlow::PathNode sink, Conf conf
32-
where conf.hasFlowPath(source, sink)
31+
from Taint::PathNode source, Taint::PathNode sink
32+
where Taint::flowPath(source, sink)
3333
select sink, source, sink, "$@", source, source.toString()

0 commit comments

Comments
 (0)