Skip to content

Add new stubs definitions to System.Web #19456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csharp/ql/test/experimental/CWE-918/options
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: ${testdir}/../../resources/stubs/System.Web.cs
semmle-extractor-options: ${testdir}/../../resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.Http.cs
4 changes: 2 additions & 2 deletions csharp/ql/test/library-tests/dataflow/global/options
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/Newtonsoft.Json/13.0.3/Newtonsoft.Json.csproj
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: --load-sources-from-project:../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: ${testdir}/../../../../../resources/stubs/System.Web.cs
semmle-extractor-options: ${testdir}/../../../../../resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs /r:System.Collections.Specialized.dll /r:System.Xml.ReaderWriter.dll /r:System.Private.Xml.dll /r:System.Runtime.Extensions.dll
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs
semmle-extractor-options: /r:System.Collections.Specialized.dll /r:System.Xml.ReaderWriter.dll /r:System.Private.Xml.dll /r:System.Runtime.Extensions.dll
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
semmle-extractor-options: /nostdlib /noconfig
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
1 change: 1 addition & 0 deletions csharp/ql/test/resources/stubs/System.Net.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class StringContent
{
public StringContent(string s) { }
}

}

namespace System.Net.Mail
Expand Down
14 changes: 14 additions & 0 deletions csharp/ql/test/resources/stubs/System.Web.Http.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace System.Web.Http
{
public class ApiController
{
public Microsoft.AspNetCore.Http.HttpContext Context => null;
public virtual Microsoft.AspNetCore.Mvc.RedirectResult Redirect(Uri location) => null;
public virtual Microsoft.AspNetCore.Mvc.RedirectResult Redirect(string location) => null;
public virtual ResponseMessageResult ResponseMessage(System.Net.Http.HttpResponseMessage response) => null;
public virtual Microsoft.AspNetCore.Mvc.RedirectToRouteResult RedirectToRoute(string routeName, object routeValues) => null;
public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; set; }
}

public class ResponseMessageResult { }
}
58 changes: 50 additions & 8 deletions csharp/ql/test/resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ public class HttpRequestBase
public class HttpResponseBase
{
public void Write(object obj) { }
public virtual void AppendHeader(string name, string value) { }
public virtual void Redirect(string url) { }
public virtual void RedirectPermanent(string url) { }
public virtual int StatusCode { get; set; }
public virtual void AddHeader(string name, string value) { }
public virtual void End() { }
public virtual string RedirectLocation { get; set; }
public virtual NameValueCollection Headers => null;

}

public class HttpContextBase
Expand Down Expand Up @@ -51,26 +60,40 @@ public class HttpApplication : IHttpHandler
}
}

namespace System.Web.Http
{
public class ApiController
{
}
}

namespace System.Web.Mvc
{
public class Controller
{
public ViewResult View() => null;
public HttpRequestBase Request => null;
public HttpResponseBase Response => null;
protected internal virtual RedirectResult RedirectPermanent(string url) => null;
protected internal RedirectToRouteResult RedirectToRoute(string routeName) => null;
public UrlHelper Url { get; set; }
protected internal virtual RedirectResult Redirect(string url) => null;
}

public class MvcHtmlString : HtmlString
{
public MvcHtmlString(string s) : base(s) { }
}

public class RoutePrefixAttribute : Attribute
{
public virtual string Prefix { get; private set; }
public RoutePrefixAttribute(string prefix) { }
}

public sealed class RouteAttribute : Attribute
{

public RouteAttribute(string template) { }
}

public class RedirectToRouteResult : ActionResult { }
}


namespace System.Web.UI
{
public class Control
Expand All @@ -81,6 +104,7 @@ public class Page
{
public System.Security.Principal.IPrincipal User { get; }
public System.Web.HttpRequest Request { get; }
public HttpResponse Response => null;
}

interface IPostBackDataHandler
Expand Down Expand Up @@ -153,6 +177,7 @@ public class HttpRequest
public UnvalidatedRequestValues Unvalidated { get; }
public string RawUrl { get; set; }
public HttpCookieCollection Cookies => null;
public bool IsAuthenticated { get; set; }
}

public class HttpRequestWrapper : System.Web.HttpRequestBase
Expand All @@ -169,6 +194,13 @@ public void WriteFile(string s) { }
public void AddHeader(string name, string value) { }
public void Redirect(string url) { }
public void AppendHeader(string name, string value) { }
public void End() { }
public string RedirectLocation { get; set; }
public int StatusCode { get; set; }
public void RedirectPermanent(string url) { }
public virtual NameValueCollection Headers { get; set; }


}

public class HttpContext : IServiceProvider
Expand All @@ -177,6 +209,7 @@ public class HttpContext : IServiceProvider
public HttpResponse Response => null;
public SessionState.HttpSessionState Session => null;
public HttpServerUtility Server => null;
public static HttpContext Current => null;
}

public class HttpCookie
Expand Down Expand Up @@ -301,6 +334,15 @@ public class UrlHelper
public UrlHelper(Routing.RequestContext requestContext) { }
public virtual bool IsLocalUrl(string url) => false;
}

public class RedirectResult : ActionResult
{
public bool Permanent { get; set; }
public string Url => null;

public RedirectResult(string url) : this(url, permanent: false) { }
public RedirectResult(string url, bool permanent) { }
}
}

namespace System.Web.Routing
Expand Down Expand Up @@ -390,7 +432,7 @@ public class JavaScriptSerializer
public JavaScriptSerializer() => throw null;
public JavaScriptSerializer(System.Web.Script.Serialization.JavaScriptTypeResolver resolver) => throw null;
public object DeserializeObject(string input) => throw null;
public T Deserialize<T> (string input) => throw null;
public T Deserialize<T>(string input) => throw null;
public object Deserialize(string input, Type targetType) => throw null;
}

Expand Down