Skip to content

Commit b789534

Browse files
Jami CogswellJami Cogswell
authored andcommitted
add csharp tests
1 parent f1ebaf1 commit b789534

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web;
4+
5+
public class SupportedExternalApis
6+
{
7+
public void M1()
8+
{
9+
var l = new List<object>(); // Uninteresting parameterless constructor
10+
var o = new object(); // Uninteresting parameterless constructor
11+
l.Add(o); // Has flow summary
12+
l.Add(o); // Has flow summary
13+
}
14+
15+
public void M2()
16+
{
17+
var d0 = new DateTime(); // Uninteresting parameterless constructor
18+
var next0 = d0.AddYears(30); // Has no flow summary, supported as negative summary
19+
20+
var d1 = new DateTime(2000, 1, 1); // Interesting constructor, supported as negative summary
21+
var next1 = next0.AddDays(3); // Has no flow summary, supported as negative summary
22+
var next2 = next1.AddYears(5); // Has no flow summary, supported as negative summary
23+
}
24+
25+
public void M3()
26+
{
27+
var guid1 = Guid.Parse("{12345678-1234-1234-1234-123456789012}"); // Has no flow summary, supported as negative summary
28+
}
29+
30+
public void M4()
31+
{
32+
var o = new object(); // Uninteresting parameterless constructor
33+
var response = new HttpResponse(); // Uninteresting parameterless constructor
34+
response.AddHeader("header", "value"); // Unsupported
35+
response.AppendHeader("header", "value"); // Unsupported
36+
response.Write(o); // Known sink
37+
response.WriteFile("filename"); // Known sink
38+
response.Write(o); // Known sink
39+
}
40+
41+
public void M5()
42+
{
43+
var l1 = Console.ReadLine(); // Known source
44+
var l2 = Console.ReadLine(); // Known source
45+
Console.SetError(Console.Out); // Has no flow summary, supported as negative summary
46+
var x = Console.Read(); // Known source
47+
}
48+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
| System#Console.ReadLine() | 2 |
2+
| System#DateTime.AddYears(System.Int32) | 2 |
3+
| System.Collections.Generic#List<>.Add(T) | 2 |
4+
| System.Web#HttpResponse.Write(System.Object) | 2 |
5+
| System#Console.Read() | 1 |
6+
| System#Console.SetError(System.IO.TextWriter) | 1 |
7+
| System#Console.get_Out() | 1 |
8+
| System#DateTime.AddDays(System.Double) | 1 |
9+
| System#DateTime.DateTime(System.Int32,System.Int32,System.Int32) | 1 |
10+
| System#Guid.Parse(System.String) | 1 |
11+
| System.Web#HttpResponse.WriteFile(System.String) | 1 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Telemetry/SupportedExternalApis.ql
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
semmle-extractor-options: /r:System.Collections.Specialized.dll
2+
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs

0 commit comments

Comments
 (0)