mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
C#: Add some source/sink examples where lifting is applied.
This commit is contained in:
@@ -4,6 +4,7 @@ extensions:
|
||||
extensible: sinkModel
|
||||
data:
|
||||
- [ "Sinks", "NewSinks", False, "Sink", "(System.Object)", "", "Argument[0]", "test-sink", "manual"]
|
||||
- [ "Sinks", "NewSinks", False, "Sink2", "(System.Object)", "", "Argument[0]", "test-sink2", "manual"]
|
||||
- [ "Sinks", "NewSinks", False, "ManualSinkAlreadyDefined", "(System.Object)", "", "Argument[0]", "test-sink", "manual"]
|
||||
|
||||
- addsTo:
|
||||
|
||||
@@ -4,6 +4,8 @@ extensions:
|
||||
extensible: sourceModel
|
||||
data:
|
||||
- ["Sources", "NewSources", False, "ManualSourceAlreadyDefined", "()", "", "ReturnValue", "test-source", "manual"]
|
||||
- ["Sources", "NewSources", False, "Source1", "()", "", "ReturnValue", "source-kind-1", "manual"]
|
||||
- ["Sources", "NewSources", False, "Source2", "()", "", "ReturnValue", "source-kind-2", "manual"]
|
||||
|
||||
- addsTo:
|
||||
pack: codeql/csharp-all
|
||||
|
||||
@@ -14,7 +14,11 @@ public class NewSinks
|
||||
|
||||
// Sink defined in the extensible file next to the test.
|
||||
// neutral=Sinks;NewSinks;Sink;(System.Object);summary;df-generated
|
||||
public void Sink(object o) => throw null;
|
||||
public static void Sink(object o) => throw null;
|
||||
|
||||
// Sink defined in the extensible file next to the test.
|
||||
// neutral=Sinks;NewSinks;Sink2;(System.Object);summary;df-generated
|
||||
public static void Sink2(object o) => throw null;
|
||||
|
||||
// New sink
|
||||
// sink=Sinks;NewSinks;false;WrapResponseWrite;(System.Object);;Argument[0];html-injection;df-generated
|
||||
@@ -105,6 +109,32 @@ public class NewSinks
|
||||
{
|
||||
Sink(o);
|
||||
}
|
||||
|
||||
public abstract class DataWriter
|
||||
{
|
||||
// neutral=Sinks;NewSinks+DataWriter;Write;(System.Object);summary;df-generated
|
||||
public abstract void Write(object o);
|
||||
}
|
||||
|
||||
public class DataWriterKind1 : DataWriter
|
||||
{
|
||||
// sink=Sinks;NewSinks+DataWriter;true;Write;(System.Object);;Argument[0];test-sink;df-generated
|
||||
// neutral=Sinks;NewSinks+DataWriterKind1;Write;(System.Object);summary;df-generated
|
||||
public override void Write(object o)
|
||||
{
|
||||
Sink(o);
|
||||
}
|
||||
}
|
||||
|
||||
public class DataWriterKind2 : DataWriter
|
||||
{
|
||||
// sink=Sinks;NewSinks+DataWriter;true;Write;(System.Object);;Argument[0];test-sink2;df-generated
|
||||
// neutral=Sinks;NewSinks+DataWriterKind2;Write;(System.Object);summary;df-generated
|
||||
public override void Write(object o)
|
||||
{
|
||||
Sink2(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CompoundSinks
|
||||
|
||||
@@ -4,6 +4,15 @@ namespace Sources;
|
||||
|
||||
public class NewSources
|
||||
{
|
||||
// Defined as source in the extensions file next to the test.
|
||||
// neutral=Sources;NewSources;Source1;();summary;df-generated
|
||||
public static string Source1() => throw null;
|
||||
|
||||
// Defined as source in the extensions file next to the test.
|
||||
// neutral=Sources;NewSources;Source2;();summary;df-generated
|
||||
public static string Source2() => throw null;
|
||||
|
||||
|
||||
// New source
|
||||
// source=Sources;NewSources;false;WrapConsoleReadLine;();;ReturnValue;local;df-generated
|
||||
// neutral=Sources;NewSources;WrapConsoleReadLine;();summary;df-generated
|
||||
@@ -79,4 +88,30 @@ public class NewSources
|
||||
{
|
||||
return Console.ReadLine();
|
||||
}
|
||||
|
||||
public abstract class DataReader
|
||||
{
|
||||
// neutral=Sources;NewSources+DataReader;Read;();summary;df-generated
|
||||
public abstract string Read();
|
||||
}
|
||||
|
||||
public class DataReaderKind1 : DataReader
|
||||
{
|
||||
// source=Sources;NewSources+DataReader;true;Read;();;ReturnValue;source-kind-1;df-generated
|
||||
// neutral=Sources;NewSources+DataReaderKind1;Read;();summary;df-generated
|
||||
public override string Read()
|
||||
{
|
||||
return Source1();
|
||||
}
|
||||
}
|
||||
|
||||
public class DataReaderKind2 : DataReader
|
||||
{
|
||||
// source=Sources;NewSources+DataReader;true;Read;();;ReturnValue;source-kind-2;df-generated
|
||||
// neutral=Sources;NewSources+DataReaderKind2;Read;();summary;df-generated
|
||||
public override string Read()
|
||||
{
|
||||
return Source2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user