mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
add csharp tests
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
|
||||
public class SupportedExternalApis
|
||||
{
|
||||
public void M1()
|
||||
{
|
||||
var l = new List<object>(); // Uninteresting parameterless constructor
|
||||
var o = new object(); // Uninteresting parameterless constructor
|
||||
l.Add(o); // Has flow summary
|
||||
l.Add(o); // Has flow summary
|
||||
}
|
||||
|
||||
public void M2()
|
||||
{
|
||||
var d0 = new DateTime(); // Uninteresting parameterless constructor
|
||||
var next0 = d0.AddYears(30); // Has no flow summary, supported as negative summary
|
||||
|
||||
var d1 = new DateTime(2000, 1, 1); // Interesting constructor, supported as negative summary
|
||||
var next1 = next0.AddDays(3); // Has no flow summary, supported as negative summary
|
||||
var next2 = next1.AddYears(5); // Has no flow summary, supported as negative summary
|
||||
}
|
||||
|
||||
public void M3()
|
||||
{
|
||||
var guid1 = Guid.Parse("{12345678-1234-1234-1234-123456789012}"); // Has no flow summary, supported as negative summary
|
||||
}
|
||||
|
||||
public void M4()
|
||||
{
|
||||
var o = new object(); // Uninteresting parameterless constructor
|
||||
var response = new HttpResponse(); // Uninteresting parameterless constructor
|
||||
response.AddHeader("header", "value"); // Unsupported
|
||||
response.AppendHeader("header", "value"); // Unsupported
|
||||
response.Write(o); // Known sink
|
||||
response.WriteFile("filename"); // Known sink
|
||||
response.Write(o); // Known sink
|
||||
}
|
||||
|
||||
public void M5()
|
||||
{
|
||||
var l1 = Console.ReadLine(); // Known source
|
||||
var l2 = Console.ReadLine(); // Known source
|
||||
Console.SetError(Console.Out); // Has no flow summary, supported as negative summary
|
||||
var x = Console.Read(); // Known source
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
| System#Console.ReadLine() | 2 |
|
||||
| System#DateTime.AddYears(System.Int32) | 2 |
|
||||
| System.Collections.Generic#List<>.Add(T) | 2 |
|
||||
| System.Web#HttpResponse.Write(System.Object) | 2 |
|
||||
| System#Console.Read() | 1 |
|
||||
| System#Console.SetError(System.IO.TextWriter) | 1 |
|
||||
| System#Console.get_Out() | 1 |
|
||||
| System#DateTime.AddDays(System.Double) | 1 |
|
||||
| System#DateTime.DateTime(System.Int32,System.Int32,System.Int32) | 1 |
|
||||
| System#Guid.Parse(System.String) | 1 |
|
||||
| System.Web#HttpResponse.WriteFile(System.String) | 1 |
|
||||
@@ -0,0 +1 @@
|
||||
Telemetry/SupportedExternalApis.ql
|
||||
@@ -0,0 +1,2 @@
|
||||
semmle-extractor-options: /r:System.Collections.Specialized.dll
|
||||
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
|
||||
Reference in New Issue
Block a user