mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
Illustrates missing flow when the sink is inside a method that is also part of a `subpath`.
52 lines
804 B
C#
52 lines
804 B
C#
using System;
|
|
|
|
public class ContentFlow
|
|
{
|
|
public class A
|
|
{
|
|
public A FieldA;
|
|
public B FieldB;
|
|
}
|
|
public class B
|
|
{
|
|
public A FieldA;
|
|
public B FieldB;
|
|
}
|
|
|
|
public void M(A a, B b)
|
|
{
|
|
var a1 = new A();
|
|
Sink(Through(a1.FieldA.FieldB));
|
|
|
|
a.FieldA.FieldB = new B();
|
|
Sink(Through(a));
|
|
|
|
var a2 = new A();
|
|
b.FieldB.FieldA = a2.FieldB.FieldA;
|
|
Sink(Through(b));
|
|
|
|
Sink(Through(Out()));
|
|
|
|
In(new A().FieldA.FieldB);
|
|
}
|
|
|
|
public static void Sink<T>(T t) { }
|
|
|
|
public T Through<T>(T t)
|
|
{
|
|
Sink(t);
|
|
return t;
|
|
}
|
|
|
|
public void In<T>(T t)
|
|
{
|
|
Sink(t);
|
|
}
|
|
|
|
public B Out()
|
|
{
|
|
var a = new A();
|
|
return a.FieldA.FieldB;
|
|
}
|
|
}
|