C#: Re-factor the ExternalFlow test.

This commit is contained in:
Michael Nebel
2023-03-31 13:39:41 +02:00
parent bd886202f6
commit a2c7388282
2 changed files with 9 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
invalidModelRow
edges
| ExternalFlow.cs:9:27:9:38 | object creation of type Object : Object | ExternalFlow.cs:10:29:10:32 | access to local variable arg1 : Object |
| 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
| ExternalFlow.cs:206:18:206:40 | call to method MixedFlowArgs | semmle.label | call to method MixedFlowArgs |
| ExternalFlow.cs:206:38:206:39 | access to local variable o2 : Object | semmle.label | access to local variable o2 : Object |
subpaths
invalidModelRow
#select
| 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 |
| 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 |

View File

@@ -3,16 +3,14 @@
*/
import csharp
import DataFlow::PathGraph
import semmle.code.csharp.dataflow.ExternalFlow
import Taint::PathGraph
import ModelValidation
class Conf extends TaintTracking::Configuration {
Conf() { this = "ExternalFlow" }
module TaintConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ObjectCreation }
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ObjectCreation }
override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
exists(MethodCall mc |
mc.getTarget().hasName("Sink") and
mc.getAnArgument() = sink.asExpr()
@@ -20,6 +18,8 @@ class Conf extends TaintTracking::Configuration {
}
}
module Taint = TaintTracking::Global<TaintConfig>;
/**
* Simulate that methods with summaries are not included in the source code.
* This is relevant for dataflow analysis using summaries tagged as generated.
@@ -28,6 +28,6 @@ private class MyMethod extends Method {
override predicate fromSource() { none() }
}
from DataFlow::PathNode source, DataFlow::PathNode sink, Conf conf
where conf.hasFlowPath(source, sink)
from Taint::PathNode source, Taint::PathNode sink
where Taint::flowPath(source, sink)
select sink, source, sink, "$@", source, source.toString()