Skip to content

Commit 2657e7f

Browse files
committed
C#: Add some source and sink modelling examples where a neutral exist.
1 parent abc7cc3 commit 2657e7f

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.ext.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ extensions:
44
extensible: sinkModel
55
data:
66
- [ "Sinks", "NewSinks", False, "Sink", "(System.Object)", "", "Argument[0]", "test-sink", "manual"]
7+
- [ "Sinks", "NewSinks", False, "ManualSinkAlreadyDefined", "(System.Object)", "", "Argument[0]", "test-sink", "manual"]
8+
9+
- addsTo:
10+
pack: codeql/csharp-all
11+
extensible: neutralModel
12+
data:
13+
- [ "Sinks", "NewSinks", "ManualSinkNeutral", "(System.Object)", "sink", "manual" ]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/csharp-all
4+
extensible: sourceModel
5+
data:
6+
- ["Sources", "NewSources", False, "ManualSourceAlreadyDefined", "()", "", "ReturnValue", "test-source", "manual"]
7+
8+
- addsTo:
9+
pack: codeql/csharp-all
10+
extensible: neutralModel
11+
data:
12+
- ["Sources", "NewSources", "ManualNeutralSource", "()", "source", "manual"]

csharp/ql/test/utils/modelgenerator/dataflow/Sinks.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ public void WrapResponseWriteFileSimpleType(string s)
9090
var r = s == "hello";
9191
Sink(r);
9292
}
93+
94+
// Not a new sink as this callable has been manually modelled
95+
// as sink neutral.
96+
// neutral=Sinks;NewSinks;ManualSinkNeutral;(System.Object);summary;df-generated
97+
public void ManualSinkNeutral(object o)
98+
{
99+
Sink(o);
100+
}
101+
102+
// Not a new sink as this callable already has a manual sink.
103+
// neutral=Sinks;NewSinks;ManualSinkAlreadyDefined;(System.Object);summary;df-generated
104+
// SPURIOUS-sink=Sinks;NewSinks;false;ManualSinkAlreadyDefined;(System.Object);;Argument[0];test-sink;df-generated
105+
public void ManualSinkAlreadyDefined(object o)
106+
{
107+
Sink(o);
108+
}
93109
}
94110

95111
public class CompoundSinks

csharp/ql/test/utils/modelgenerator/dataflow/Sources.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,21 @@ public string Read()
6464
return Value.ToString();
6565
}
6666
}
67+
68+
// Not a new source as this callable has been manually modelled
69+
// as source neutral.
70+
// neutral=Sources;NewSources;ManualNeutralSource;();summary;df-generated
71+
// SPURIOUS-source=Sources;NewSources;false;ManualNeutralSource;();;ReturnValue;local;df-generated
72+
public string ManualNeutralSource()
73+
{
74+
return Console.ReadLine();
75+
}
76+
77+
// Not a new source as this callable already has a manual source.
78+
// SPURIOUS-source=Sources;NewSources;false;ManualSourceAlreadyDefined;();;ReturnValue;local;df-generated
79+
// neutral=Sources;NewSources;ManualSourceAlreadyDefined;();summary;df-generated
80+
public string ManualSourceAlreadyDefined()
81+
{
82+
return Console.ReadLine();
83+
}
6784
}

0 commit comments

Comments
 (0)