Skip to content

Commit 45eb149

Browse files
committed
C#: Inline expectation should have space after $
This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `.
1 parent badfa1a commit 45eb149

File tree

4 files changed

+22
-22
lines changed
  • csharp/ql/test/query-tests/Security Features

4 files changed

+22
-22
lines changed

csharp/ql/test/query-tests/Security Features/CWE-1004/HttpOnlyCookie/AspNetCore/NoPolicy/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ public class MyController : Microsoft.AspNetCore.Mvc.Controller
22
{
33
public void CookieDefault()
44
{
5-
Response.Cookies.Append("auth", "value"); // $Alert // BAD: HttpOnly is set to false by default
5+
Response.Cookies.Append("auth", "value"); // $ Alert // BAD: HttpOnly is set to false by default
66
}
77

88
public void CookieDefault2()
99
{
10-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $Alert
10+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $ Alert
1111
Response.Cookies.Append("auth", "value", cookieOptions); // BAD: HttpOnly is set to false by default
1212
}
1313

@@ -39,14 +39,14 @@ void CookieDirectTrueInitializer()
3939

4040
void CookieDirectFalse()
4141
{
42-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $Alert
42+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $ Alert
4343
cookieOptions.HttpOnly = false;
4444
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD
4545
}
4646

4747
void CookieDirectFalseInitializer()
4848
{
49-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { HttpOnly = false }; // $Alert
49+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { HttpOnly = false }; // $ Alert
5050
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD
5151
}
5252

@@ -67,7 +67,7 @@ void CookieIntermediateTrueInitializer()
6767

6868
void CookieIntermediateFalse()
6969
{
70-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $MISSING:Alert
70+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $ MISSING:Alert
7171
bool v = false;
7272
cookieOptions.HttpOnly = v;
7373
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD, but not detected
@@ -76,7 +76,7 @@ void CookieIntermediateFalse()
7676
void CookieIntermediateFalseInitializer()
7777
{
7878
bool v = false;
79-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { HttpOnly = v }; // $MISSING:Alert
79+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { HttpOnly = v }; // $ MISSING:Alert
8080
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD, but not detected
8181
}
8282
}

csharp/ql/test/query-tests/Security Features/CWE-1004/HttpOnlyCookie/SystemWeb/HttpOnlyCookiesFalse/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void CookieDirectTrueInitializer()
1313

1414
void CookieDefault()
1515
{
16-
var cookie = new System.Web.HttpCookie("sessionID"); // $Alert // BAD: httpOnlyCookies is set to false by default
16+
var cookie = new System.Web.HttpCookie("sessionID"); // $ Alert // BAD: httpOnlyCookies is set to false by default
1717
}
1818

1919
void CookieDefaultForgery()
@@ -29,13 +29,13 @@ void CookieForgeryDirectFalse()
2929

3030
void CookieDirectFalse()
3131
{
32-
var cookie = new System.Web.HttpCookie("sessionID"); // $Alert
32+
var cookie = new System.Web.HttpCookie("sessionID"); // $ Alert
3333
cookie.HttpOnly = false; // BAD
3434
}
3535

3636
void CookieDirectFalseInitializer()
3737
{
38-
var cookie = new System.Web.HttpCookie("sessionID") { HttpOnly = false }; // $Alert // BAD
38+
var cookie = new System.Web.HttpCookie("sessionID") { HttpOnly = false }; // $ Alert // BAD
3939
}
4040

4141
void CookieIntermediateTrue()
@@ -53,14 +53,14 @@ void CookieIntermediateTrueInitializer()
5353

5454
void CookieIntermediateFalse()
5555
{
56-
var cookie = new System.Web.HttpCookie("sessionID"); // MISSING:Alert
56+
var cookie = new System.Web.HttpCookie("sessionID"); // MISSING:Alert
5757
bool v = false;
5858
cookie.HttpOnly = v; // BAD
5959
}
6060

6161
void CookieIntermediateFalseInitializer()
6262
{
6363
bool v = false;
64-
var cookie = new System.Web.HttpCookie("sessionID") { HttpOnly = v }; // $MISSING:Alert // BAD
64+
var cookie = new System.Web.HttpCookie("sessionID") { HttpOnly = v }; // $ MISSING:Alert // BAD
6565
}
6666
}

csharp/ql/test/query-tests/Security Features/CWE-614/InsecureCookie/AspNetCore/NoPolicy/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ public class MyController : Microsoft.AspNetCore.Mvc.Controller
22
{
33
public void CookieDefault()
44
{
5-
Response.Cookies.Append("name", "value"); // $Alert // BAD: Secure is set to false by default
5+
Response.Cookies.Append("name", "value"); // $ Alert // BAD: Secure is set to false by default
66
}
77

88
public void CookieDefault2()
99
{
10-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $Alert
10+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $ Alert
1111
Response.Cookies.Append("name", "value", cookieOptions); // BAD: Secure is set to false by default
1212
}
1313

@@ -32,14 +32,14 @@ void CookieDirectTrueInitializer()
3232

3333
void CookieDirectFalse()
3434
{
35-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $Alert
35+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $ Alert
3636
cookieOptions.Secure = false;
3737
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD
3838
}
3939

4040
void CookieDirectFalseInitializer()
4141
{
42-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { Secure = false }; // $Alert
42+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { Secure = false }; // $ Alert
4343
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD
4444
}
4545

@@ -60,7 +60,7 @@ void CookieIntermediateTrueInitializer()
6060

6161
void CookieIntermediateFalse()
6262
{
63-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $MISSING:Alert
63+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions(); // $ MISSING:Alert
6464
bool v = false;
6565
cookieOptions.Secure = v;
6666
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD, but not detected
@@ -69,7 +69,7 @@ void CookieIntermediateFalse()
6969
void CookieIntermediateFalseInitializer()
7070
{
7171
bool v = false;
72-
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { Secure = v }; // $MISSING:Alert
72+
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions() { Secure = v }; // $ MISSING:Alert
7373
Response.Cookies.Append("auth", "secret", cookieOptions); // BAD, but not detected
7474
}
7575
}

csharp/ql/test/query-tests/Security Features/CWE-614/InsecureCookie/SystemWeb/RequireSSLFalse/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Program
22
{
33
void CookieDefault()
44
{
5-
var cookie = new System.Web.HttpCookie("cookieName"); // $Alert // BAD: requireSSL is set to false by default
5+
var cookie = new System.Web.HttpCookie("cookieName"); // $ Alert // BAD: requireSSL is set to false by default
66
}
77

88
void CookieDirectTrue()
@@ -31,25 +31,25 @@ void CookieIntermediateTrueInitializer()
3131

3232
void CookieDirectFalse()
3333
{
34-
var cookie = new System.Web.HttpCookie("cookieName"); // $Alert
34+
var cookie = new System.Web.HttpCookie("cookieName"); // $ Alert
3535
cookie.Secure = false; // BAD
3636
}
3737

3838
void CookieDirectFalseInitializer()
3939
{
40-
var cookie = new System.Web.HttpCookie("cookieName") { Secure = false }; // $Alert // BAD
40+
var cookie = new System.Web.HttpCookie("cookieName") { Secure = false }; // $ Alert // BAD
4141
}
4242

4343
void CookieIntermediateFalse()
4444
{
45-
var cookie = new System.Web.HttpCookie("cookieName"); // $MISSING:Alert
45+
var cookie = new System.Web.HttpCookie("cookieName"); // $ MISSING:Alert
4646
bool v = false;
4747
cookie.Secure = v; // BAD, but not detected
4848
}
4949

5050
void CookieIntermediateFalseInitializer()
5151
{
5252
bool v = false;
53-
var cookie = new System.Web.HttpCookie("cookieName") { Secure = v }; // $MISSING:Alert // BAD, but not detected
53+
var cookie = new System.Web.HttpCookie("cookieName") { Secure = v }; // $ MISSING:Alert // BAD, but not detected
5454
}
5555
}

0 commit comments

Comments
 (0)