Skip to content

Commit b674a8e

Browse files
committed
C#: Split the StoredXss test from XSS Asp test. Make the former based on stubs.
1 parent 0d10f5c commit b674a8e

File tree

10 files changed

+15
-13
lines changed

10 files changed

+15
-13
lines changed

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/StoredXSS.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// semmle-extractor-options: /r:${testdir}/../../../../resources/assemblies/System.Data.dll /r:${testdir}/../../../../resources/assemblies/System.Web.dll /r:${testdir}/../../../../resources/assemblies/System.Web.Mvc.dll /r:System.ComponentModel.Primitives.dll /r:System.Collections.Specialized.dll /r:${testdir}/../../../../resources/assemblies/System.Net.Http.dll
2-
31
using System;
42
using System.Data.SqlClient;
53
using System.Web;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
edges
2-
| StoredXSS.cs:24:60:24:86 | call to method GetString : String | StoredXSS.cs:24:44:24:86 | ... + ... |
2+
| StoredXSS.cs:22:60:22:86 | call to method GetString : String | StoredXSS.cs:22:44:22:86 | ... + ... |
33
nodes
4-
| StoredXSS.cs:24:44:24:86 | ... + ... | semmle.label | ... + ... |
5-
| StoredXSS.cs:24:60:24:86 | call to method GetString : String | semmle.label | call to method GetString : String |
4+
| StoredXSS.cs:22:44:22:86 | ... + ... | semmle.label | ... + ... |
5+
| StoredXSS.cs:22:60:22:86 | call to method GetString : String | semmle.label | call to method GetString : String |
66
subpaths
77
#select
8-
| StoredXSS.cs:24:44:24:86 | ... + ... | StoredXSS.cs:24:60:24:86 | call to method GetString : String | StoredXSS.cs:24:44:24:86 | ... + ... | This HTML or JavaScript write depends on a $@. | StoredXSS.cs:24:60:24:86 | call to method GetString | stored (potentially user-provided) value |
8+
| StoredXSS.cs:22:44:22:86 | ... + ... | StoredXSS.cs:22:60:22:86 | call to method GetString : String | StoredXSS.cs:22:44:22:86 | ... + ... | This HTML or JavaScript write depends on a $@. | StoredXSS.cs:22:60:22:86 | call to method GetString | stored (potentially user-provided) value |
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Net.cs
1+
semmle-extractor-options: /nostdlib /noconfig
2+
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../resources/stubs/System.Data.SqlClient/4.8.3/System.Data.SqlClient.csproj
3+
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/AspInline.expected renamed to csharp/ql/test/query-tests/Security Features/CWE-079/XSSAsp/AspInline.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| script.aspx:4:1:4:23 | <%= ... %> | XSS.cs:114:16:114:29 | someJavascript |
2-
| script.aspx:8:1:8:12 | <%= ... %> | XSS.cs:121:24:121:28 | Field |
1+
| script.aspx:4:1:4:23 | <%= ... %> | XSS.cs:115:16:115:29 | someJavascript |
2+
| script.aspx:8:1:8:12 | <%= ... %> | XSS.cs:122:24:122:28 | Field |
33
| script.aspx:12:1:12:14 | <%= ... %> | <outside test directory> | Request |
44
| script.aspx:16:1:16:34 | <%= ... %> | <outside test directory> | QueryString |
55
| script.aspx:20:1:20:41 | <%= ... %> | <outside test directory> | QueryString |

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/AspInline.ql renamed to csharp/ql/test/query-tests/Security Features/CWE-079/XSSAsp/AspInline.ql

File renamed without changes.

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/XSS.cs renamed to csharp/ql/test/query-tests/Security Features/CWE-079/XSSAsp/XSS.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
// semmle-extractor-options: /r:${testdir}/../../../../resources/assemblies/System.Web.dll /r:${testdir}/../../../../resources/assemblies/System.Web.Mvc.dll /r:System.Collections.Specialized.dll /r:${testdir}/../../../../resources/assemblies/System.Net.Http.dll
22
using System;
33
using System.Net;
44
using System.Net.Http;
@@ -102,7 +102,8 @@ public void HtmlEncoded(HttpContextBase context)
102102
new StringContent(HttpUtility.HtmlEncode(name));
103103
}
104104

105-
public void UrlEncoded(HttpContextBase context) {
105+
public void UrlEncoded(HttpContextBase context)
106+
{
106107
// GOOD: URL encoding
107108
string name = context.Request.QueryString["name"];
108109
new StringContent(HttpUtility.UrlEncode(name));

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/XSS.expected renamed to csharp/ql/test/query-tests/Security Features/CWE-079/XSSAsp/XSS.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ nodes
5656
| XSS.cs:94:27:94:53 | access to property QueryString : NameValueCollection | semmle.label | access to property QueryString : NameValueCollection |
5757
| XSS.cs:94:27:94:61 | access to indexer : String | semmle.label | access to indexer : String |
5858
| XSS.cs:95:31:95:34 | access to local variable name | semmle.label | access to local variable name |
59-
| XSS.cs:134:20:134:33 | access to property RawUrl | semmle.label | access to property RawUrl |
59+
| XSS.cs:135:20:135:33 | access to property RawUrl | semmle.label | access to property RawUrl |
6060
| script.aspx:12:1:12:14 | <%= ... %> | semmle.label | <%= ... %> |
6161
| script.aspx:16:1:16:34 | <%= ... %> | semmle.label | <%= ... %> |
6262
| script.aspx:20:1:20:41 | <%= ... %> | semmle.label | <%= ... %> |
@@ -72,7 +72,7 @@ subpaths
7272
| XSS.cs:86:28:86:31 | access to local variable name | XSS.cs:85:27:85:53 | access to property QueryString : NameValueCollection | XSS.cs:86:28:86:31 | access to local variable name | $@ flows to here and is written to HTML or JavaScript. | XSS.cs:85:27:85:53 | access to property QueryString : NameValueCollection | User-provided value |
7373
| XSS.cs:87:31:87:34 | access to local variable name | XSS.cs:85:27:85:53 | access to property QueryString : NameValueCollection | XSS.cs:87:31:87:34 | access to local variable name | $@ flows to here and is written to HTML or JavaScript. | XSS.cs:85:27:85:53 | access to property QueryString : NameValueCollection | User-provided value |
7474
| XSS.cs:95:31:95:34 | access to local variable name | XSS.cs:94:27:94:53 | access to property QueryString : NameValueCollection | XSS.cs:95:31:95:34 | access to local variable name | $@ flows to here and is written to HTML or JavaScript. | XSS.cs:94:27:94:53 | access to property QueryString : NameValueCollection | User-provided value |
75-
| XSS.cs:134:20:134:33 | access to property RawUrl | XSS.cs:134:20:134:33 | access to property RawUrl | XSS.cs:134:20:134:33 | access to property RawUrl | $@ flows to here and is written to HTML or JavaScript. | XSS.cs:134:20:134:33 | access to property RawUrl | User-provided value |
75+
| XSS.cs:135:20:135:33 | access to property RawUrl | XSS.cs:135:20:135:33 | access to property RawUrl | XSS.cs:135:20:135:33 | access to property RawUrl | $@ flows to here and is written to HTML or JavaScript. | XSS.cs:135:20:135:33 | access to property RawUrl | User-provided value |
7676
| script.aspx:12:1:12:14 | <%= ... %> | script.aspx:12:1:12:14 | <%= ... %> | script.aspx:12:1:12:14 | <%= ... %> | $@ flows to here and is a remote source accessed inline in an ASPX page. | script.aspx:12:1:12:14 | <%= ... %> | User-provided value |
7777
| script.aspx:16:1:16:34 | <%= ... %> | script.aspx:16:1:16:34 | <%= ... %> | script.aspx:16:1:16:34 | <%= ... %> | $@ flows to here and is a remote source accessed inline in an ASPX page. | script.aspx:16:1:16:34 | <%= ... %> | User-provided value |
7878
| script.aspx:20:1:20:41 | <%= ... %> | script.aspx:20:1:20:41 | <%= ... %> | script.aspx:20:1:20:41 | <%= ... %> | $@ flows to here and is a remote source accessed inline in an ASPX page. | script.aspx:20:1:20:41 | <%= ... %> | User-provided value |

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/XSS.qlref renamed to csharp/ql/test/query-tests/Security Features/CWE-079/XSSAsp/XSS.qlref

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Net.cs

csharp/ql/test/query-tests/Security Features/CWE-079/StoredXSS/script.aspx renamed to csharp/ql/test/query-tests/Security Features/CWE-079/XSSAsp/script.aspx

File renamed without changes.

0 commit comments

Comments
 (0)