mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
C#: Add some source and sink modelling examples where a neutral exist.
This commit is contained in:
@@ -4,3 +4,10 @@ extensions:
|
||||
extensible: sinkModel
|
||||
data:
|
||||
- [ "Sinks", "NewSinks", False, "Sink", "(System.Object)", "", "Argument[0]", "test-sink", "manual"]
|
||||
- [ "Sinks", "NewSinks", False, "ManualSinkAlreadyDefined", "(System.Object)", "", "Argument[0]", "test-sink", "manual"]
|
||||
|
||||
- addsTo:
|
||||
pack: codeql/csharp-all
|
||||
extensible: neutralModel
|
||||
data:
|
||||
- [ "Sinks", "NewSinks", "ManualSinkNeutral", "(System.Object)", "sink", "manual" ]
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/csharp-all
|
||||
extensible: sourceModel
|
||||
data:
|
||||
- ["Sources", "NewSources", False, "ManualSourceAlreadyDefined", "()", "", "ReturnValue", "test-source", "manual"]
|
||||
|
||||
- addsTo:
|
||||
pack: codeql/csharp-all
|
||||
extensible: neutralModel
|
||||
data:
|
||||
- ["Sources", "NewSources", "ManualNeutralSource", "()", "source", "manual"]
|
||||
@@ -90,6 +90,22 @@ public class NewSinks
|
||||
var r = s == "hello";
|
||||
Sink(r);
|
||||
}
|
||||
|
||||
// Not a new sink as this callable has been manually modelled
|
||||
// as sink neutral.
|
||||
// neutral=Sinks;NewSinks;ManualSinkNeutral;(System.Object);summary;df-generated
|
||||
public void ManualSinkNeutral(object o)
|
||||
{
|
||||
Sink(o);
|
||||
}
|
||||
|
||||
// Not a new sink as this callable already has a manual sink.
|
||||
// neutral=Sinks;NewSinks;ManualSinkAlreadyDefined;(System.Object);summary;df-generated
|
||||
// SPURIOUS-sink=Sinks;NewSinks;false;ManualSinkAlreadyDefined;(System.Object);;Argument[0];test-sink;df-generated
|
||||
public void ManualSinkAlreadyDefined(object o)
|
||||
{
|
||||
Sink(o);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompoundSinks
|
||||
|
||||
@@ -64,4 +64,21 @@ public class NewSources
|
||||
return Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// Not a new source as this callable has been manually modelled
|
||||
// as source neutral.
|
||||
// neutral=Sources;NewSources;ManualNeutralSource;();summary;df-generated
|
||||
// SPURIOUS-source=Sources;NewSources;false;ManualNeutralSource;();;ReturnValue;local;df-generated
|
||||
public string ManualNeutralSource()
|
||||
{
|
||||
return Console.ReadLine();
|
||||
}
|
||||
|
||||
// Not a new source as this callable already has a manual source.
|
||||
// SPURIOUS-source=Sources;NewSources;false;ManualSourceAlreadyDefined;();;ReturnValue;local;df-generated
|
||||
// neutral=Sources;NewSources;ManualSourceAlreadyDefined;();summary;df-generated
|
||||
public string ManualSourceAlreadyDefined()
|
||||
{
|
||||
return Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user