Skip to content

Commit caef6a4

Browse files
committed
C#: Add example of failing taint flow for collections in sinks.
1 parent ededa3c commit caef6a4

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class CollectionTaintTracking
2+
{
3+
public void ImplicitCollectionReadAtSink()
4+
{
5+
var tainted = Source<object>(1);
6+
var arr = new object[] { tainted };
7+
Sink(arr); // $ hasTaintFlow=1
8+
}
9+
10+
static T Source<T>(object source) => throw null;
11+
12+
public static void Sink<T>(T t) { }
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
models
2+
edges
3+
nodes
4+
subpaths
5+
testFailures
6+
| CollectionTaintTracking.cs:10:20:10:38 | // ... | Missing result: hasTaintFlow=1 |
7+
#select
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
5+
import csharp
6+
import utils.test.InlineFlowTest
7+
import TaintFlowTest<DefaultFlowConfig>
8+
import PathGraph
9+
10+
from PathNode source, PathNode sink
11+
where flowPath(source, sink)
12+
select sink, source, sink, "$@", source, source.toString()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
semmle-extractor-options: /nostdlib /noconfig
2+
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj

0 commit comments

Comments
 (0)