Skip to content

Commit 47ab206

Browse files
committed
C#: Replace StringValues stub from stubs.cs with the stub in Microsoft.Extensions.Primitives.
1 parent b3f3c2d commit 47ab206

File tree

2 files changed

+136
-166
lines changed
  • csharp/ql/test/query-tests/Security Features/CWE-601/UrlRedirect

2 files changed

+136
-166
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
semmle-extractor-options: /nostdlib /noconfig
22
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3+
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/Microsoft.Extensions.Primitives/6.0.0/Microsoft.Extensions.Primitives.csproj
34
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs
Lines changed: 135 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,138 @@
11
namespace Microsoft
22
{
3-
namespace AspNetCore
4-
{
5-
namespace Http
6-
{
7-
// Generated from `Microsoft.AspNetCore.Http.HeaderDictionaryExtensions` in `Microsoft.AspNetCore.Http.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
8-
static public class HeaderDictionaryExtensions
9-
{
10-
public static void Append(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, Microsoft.Extensions.Primitives.StringValues value) => throw null;
11-
public static void AppendCommaSeparatedValues(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, params string[] values) => throw null;
12-
public static void SetCommaSeparatedValues(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, params string[] values) => throw null;
13-
}
14-
15-
// Generated from `Microsoft.AspNetCore.Http.HttpResponse` in `Microsoft.AspNetCore.Http.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
16-
abstract public class HttpResponse
17-
{
18-
public abstract Microsoft.AspNetCore.Http.IHeaderDictionary Headers { get; }
19-
public virtual void Redirect(string location) => throw null;
20-
}
21-
22-
// Generated from `Microsoft.AspNetCore.Http.IHeaderDictionary` in `Microsoft.AspNetCore.Http.Features, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
23-
public interface IHeaderDictionary : System.Collections.IEnumerable, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,Microsoft.Extensions.Primitives.StringValues>>, System.Collections.Generic.IDictionary<string,Microsoft.Extensions.Primitives.StringValues>, System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,Microsoft.Extensions.Primitives.StringValues>>
24-
{
25-
Microsoft.Extensions.Primitives.StringValues this[string key] { get; set; }
26-
}
27-
28-
namespace Headers
29-
{
30-
// Generated from `Microsoft.AspNetCore.Http.Headers.ResponseHeaders` in `Microsoft.AspNetCore.Http.Extensions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
31-
public class ResponseHeaders
32-
{
33-
public ResponseHeaders(Microsoft.AspNetCore.Http.IHeaderDictionary headers) => throw null;
34-
public System.Uri Location { get => throw null; set => throw null; }
35-
}
36-
37-
}
38-
}
39-
namespace Mvc
40-
{
41-
// Generated from `Microsoft.AspNetCore.Mvc.ActionResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
42-
abstract public class ActionResult : Microsoft.AspNetCore.Mvc.IActionResult
43-
{
44-
}
45-
46-
// Generated from `Microsoft.AspNetCore.Mvc.ControllerBase` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
47-
abstract public class ControllerBase
48-
{
49-
public Microsoft.AspNetCore.Http.HttpResponse Response { get => throw null; }
50-
public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get => throw null; set => throw null; }
51-
public virtual Microsoft.AspNetCore.Mvc.RedirectResult Redirect(string url) => throw null;
52-
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToActionPermanent(string actionName) => throw null;
53-
public virtual Microsoft.AspNetCore.Mvc.RedirectToPageResult RedirectToPage(string pageName) => throw null;
54-
}
55-
56-
// Generated from `Microsoft.AspNetCore.Mvc.FromBodyAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
57-
public class FromBodyAttribute : System.Attribute, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata
58-
{
59-
public FromBodyAttribute() => throw null;
60-
}
61-
62-
// Generated from `Microsoft.AspNetCore.Mvc.HttpPostAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
63-
public class HttpPostAttribute : Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute
64-
{
65-
public HttpPostAttribute() => throw null;
66-
public HttpPostAttribute(string template) => throw null;
67-
}
68-
69-
// Generated from `Microsoft.AspNetCore.Mvc.HttpPutAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
70-
public class HttpPutAttribute : Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute
71-
{
72-
public HttpPutAttribute() => throw null;
73-
public HttpPutAttribute(string template) => throw null;
74-
}
75-
76-
// Generated from `Microsoft.AspNetCore.Mvc.IActionResult` in `Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
77-
public interface IActionResult
78-
{
79-
}
80-
81-
// Generated from `Microsoft.AspNetCore.Mvc.IUrlHelper` in `Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
82-
public interface IUrlHelper
83-
{
84-
bool IsLocalUrl(string url);
85-
}
86-
87-
// Generated from `Microsoft.AspNetCore.Mvc.RedirectResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
88-
public class RedirectResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult, Microsoft.AspNetCore.Mvc.IActionResult
89-
{
90-
}
91-
92-
// Generated from `Microsoft.AspNetCore.Mvc.RedirectToActionResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
93-
public class RedirectToActionResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult, Microsoft.AspNetCore.Mvc.IActionResult
94-
{
95-
}
96-
97-
// Generated from `Microsoft.AspNetCore.Mvc.RedirectToPageResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
98-
public class RedirectToPageResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult, Microsoft.AspNetCore.Mvc.IActionResult
99-
{
100-
}
101-
102-
namespace ModelBinding
103-
{
104-
// Generated from `Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata` in `Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
105-
public interface IBindingSourceMetadata
106-
{
107-
}
108-
109-
}
110-
namespace Routing
111-
{
112-
// Generated from `Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
113-
abstract public class HttpMethodAttribute : System.Attribute, Microsoft.AspNetCore.Mvc.Routing.IRouteTemplateProvider, Microsoft.AspNetCore.Mvc.Routing.IActionHttpMethodProvider
114-
{
115-
}
116-
117-
// Generated from `Microsoft.AspNetCore.Mvc.Routing.IActionHttpMethodProvider` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
118-
public interface IActionHttpMethodProvider
119-
{
120-
}
121-
122-
// Generated from `Microsoft.AspNetCore.Mvc.Routing.IRouteTemplateProvider` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
123-
public interface IRouteTemplateProvider
124-
{
125-
}
126-
127-
}
128-
namespace ViewFeatures
129-
{
130-
// Generated from `Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
131-
public interface IKeepTempDataResult : Microsoft.AspNetCore.Mvc.IActionResult
132-
{
133-
}
134-
135-
}
136-
}
137-
}
138-
namespace Extensions
139-
{
140-
namespace Primitives
141-
{
142-
// Generated from `Microsoft.Extensions.Primitives.StringValues` in `Microsoft.Extensions.Primitives, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
143-
public struct StringValues : System.IEquatable<string[]>, System.IEquatable<string>, System.IEquatable<Microsoft.Extensions.Primitives.StringValues>, System.Collections.IEnumerable, System.Collections.Generic.IReadOnlyList<string>, System.Collections.Generic.IReadOnlyCollection<string>, System.Collections.Generic.IList<string>, System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.ICollection<string>
144-
{
145-
System.Collections.Generic.IEnumerator<string> System.Collections.Generic.IEnumerable<string>.GetEnumerator() => throw null;
146-
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => throw null;
147-
bool System.Collections.Generic.ICollection<string>.Contains(string item) => throw null;
148-
bool System.Collections.Generic.ICollection<string>.IsReadOnly { get => throw null; }
149-
bool System.Collections.Generic.ICollection<string>.Remove(string item) => throw null;
150-
int System.Collections.Generic.IList<string>.IndexOf(string item) => throw null;
151-
public bool Equals(Microsoft.Extensions.Primitives.StringValues other) => throw null;
152-
public bool Equals(string other) => throw null;
153-
public bool Equals(string[] other) => throw null;
154-
public int Count { get => throw null; }
155-
public override bool Equals(object obj) => throw null;
156-
public override int GetHashCode() => throw null;
157-
public override string ToString() => throw null;
158-
public static implicit operator Microsoft.Extensions.Primitives.StringValues(string value) => throw null;
159-
void System.Collections.Generic.ICollection<string>.Add(string item) => throw null;
160-
void System.Collections.Generic.ICollection<string>.Clear() => throw null;
161-
void System.Collections.Generic.ICollection<string>.CopyTo(string[] array, int arrayIndex) => throw null;
162-
void System.Collections.Generic.IList<string>.Insert(int index, string item) => throw null;
163-
void System.Collections.Generic.IList<string>.RemoveAt(int index) => throw null;
164-
public string this[int i] { get => throw null; set => throw null; }
165-
}
166-
167-
}
168-
}
3+
namespace AspNetCore
4+
{
5+
namespace Http
6+
{
7+
// Generated from `Microsoft.AspNetCore.Http.HeaderDictionaryExtensions` in `Microsoft.AspNetCore.Http.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
8+
static public class HeaderDictionaryExtensions
9+
{
10+
public static void Append(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, Microsoft.Extensions.Primitives.StringValues value) => throw null;
11+
public static void AppendCommaSeparatedValues(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, params string[] values) => throw null;
12+
public static void SetCommaSeparatedValues(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string key, params string[] values) => throw null;
13+
}
14+
15+
// Generated from `Microsoft.AspNetCore.Http.HttpResponse` in `Microsoft.AspNetCore.Http.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
16+
abstract public class HttpResponse
17+
{
18+
public abstract Microsoft.AspNetCore.Http.IHeaderDictionary Headers { get; }
19+
public virtual void Redirect(string location) => throw null;
20+
}
21+
22+
// Generated from `Microsoft.AspNetCore.Http.IHeaderDictionary` in `Microsoft.AspNetCore.Http.Features, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
23+
public interface IHeaderDictionary : System.Collections.IEnumerable, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>, System.Collections.Generic.IDictionary<string, Microsoft.Extensions.Primitives.StringValues>, System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, Microsoft.Extensions.Primitives.StringValues>>
24+
{
25+
Microsoft.Extensions.Primitives.StringValues this[string key] { get; set; }
26+
}
27+
28+
namespace Headers
29+
{
30+
// Generated from `Microsoft.AspNetCore.Http.Headers.ResponseHeaders` in `Microsoft.AspNetCore.Http.Extensions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
31+
public class ResponseHeaders
32+
{
33+
public ResponseHeaders(Microsoft.AspNetCore.Http.IHeaderDictionary headers) => throw null;
34+
public System.Uri Location { get => throw null; set => throw null; }
35+
}
36+
37+
}
38+
}
39+
namespace Mvc
40+
{
41+
// Generated from `Microsoft.AspNetCore.Mvc.ActionResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
42+
abstract public class ActionResult : Microsoft.AspNetCore.Mvc.IActionResult
43+
{
44+
}
45+
46+
// Generated from `Microsoft.AspNetCore.Mvc.ControllerBase` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
47+
abstract public class ControllerBase
48+
{
49+
public Microsoft.AspNetCore.Http.HttpResponse Response { get => throw null; }
50+
public Microsoft.AspNetCore.Mvc.IUrlHelper Url { get => throw null; set => throw null; }
51+
public virtual Microsoft.AspNetCore.Mvc.RedirectResult Redirect(string url) => throw null;
52+
public virtual Microsoft.AspNetCore.Mvc.RedirectToActionResult RedirectToActionPermanent(string actionName) => throw null;
53+
public virtual Microsoft.AspNetCore.Mvc.RedirectToPageResult RedirectToPage(string pageName) => throw null;
54+
}
55+
56+
// Generated from `Microsoft.AspNetCore.Mvc.FromBodyAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
57+
public class FromBodyAttribute : System.Attribute, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata
58+
{
59+
public FromBodyAttribute() => throw null;
60+
}
61+
62+
// Generated from `Microsoft.AspNetCore.Mvc.HttpPostAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
63+
public class HttpPostAttribute : Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute
64+
{
65+
public HttpPostAttribute() => throw null;
66+
public HttpPostAttribute(string template) => throw null;
67+
}
68+
69+
// Generated from `Microsoft.AspNetCore.Mvc.HttpPutAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
70+
public class HttpPutAttribute : Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute
71+
{
72+
public HttpPutAttribute() => throw null;
73+
public HttpPutAttribute(string template) => throw null;
74+
}
75+
76+
// Generated from `Microsoft.AspNetCore.Mvc.IActionResult` in `Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
77+
public interface IActionResult
78+
{
79+
}
80+
81+
// Generated from `Microsoft.AspNetCore.Mvc.IUrlHelper` in `Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
82+
public interface IUrlHelper
83+
{
84+
bool IsLocalUrl(string url);
85+
}
86+
87+
// Generated from `Microsoft.AspNetCore.Mvc.RedirectResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
88+
public class RedirectResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult, Microsoft.AspNetCore.Mvc.IActionResult
89+
{
90+
}
91+
92+
// Generated from `Microsoft.AspNetCore.Mvc.RedirectToActionResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
93+
public class RedirectToActionResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult, Microsoft.AspNetCore.Mvc.IActionResult
94+
{
95+
}
96+
97+
// Generated from `Microsoft.AspNetCore.Mvc.RedirectToPageResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
98+
public class RedirectToPageResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult, Microsoft.AspNetCore.Mvc.IActionResult
99+
{
100+
}
101+
102+
namespace ModelBinding
103+
{
104+
// Generated from `Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata` in `Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
105+
public interface IBindingSourceMetadata
106+
{
107+
}
108+
109+
}
110+
namespace Routing
111+
{
112+
// Generated from `Microsoft.AspNetCore.Mvc.Routing.HttpMethodAttribute` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
113+
abstract public class HttpMethodAttribute : System.Attribute, Microsoft.AspNetCore.Mvc.Routing.IRouteTemplateProvider, Microsoft.AspNetCore.Mvc.Routing.IActionHttpMethodProvider
114+
{
115+
}
116+
117+
// Generated from `Microsoft.AspNetCore.Mvc.Routing.IActionHttpMethodProvider` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
118+
public interface IActionHttpMethodProvider
119+
{
120+
}
121+
122+
// Generated from `Microsoft.AspNetCore.Mvc.Routing.IRouteTemplateProvider` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
123+
public interface IRouteTemplateProvider
124+
{
125+
}
126+
127+
}
128+
namespace ViewFeatures
129+
{
130+
// Generated from `Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult` in `Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`
131+
public interface IKeepTempDataResult : Microsoft.AspNetCore.Mvc.IActionResult
132+
{
133+
}
134+
135+
}
136+
}
137+
}
169138
}

0 commit comments

Comments
 (0)