Skip to content

Commit bdaeeea

Browse files
Add good/bad indicators to tests
1 parent 270bcc3 commit bdaeeea

File tree

9 files changed

+15
-4
lines changed

9 files changed

+15
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| ProfileController.cs:7:25:7:31 | Delete1 | This action is missing an authorization check. |
1+
| ProfileController.cs:8:25:8:31 | Delete1 | This action is missing an authorization check. |

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/MVCTests/ProfileController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ public class ProfileController : Controller {
44
private void doThings() { }
55
private bool isAuthorized() { return false; }
66

7+
// BAD: This is a Delete method, but no auth is specified.
78
public ActionResult Delete1(int id) {
89
doThings();
910
return View();
1011
}
1112

13+
// GOOD: isAuthorized is checked.
1214
public ActionResult Delete2(int id) {
1315
if (!isAuthorized()) {
1416
return null;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| Test1/EditProfile.aspx.cs:9:20:9:29 | btn1_Click | This action is missing an authorization check. |
2-
| Test1/ViewProfile.aspx.cs:12:20:12:36 | btn_delete1_Click | This action is missing an authorization check. |
3-
| Test3/B/EditProfile.aspx.cs:7:20:7:29 | btn1_Click | This action is missing an authorization check. |
1+
| Test1/EditProfile.aspx.cs:10:20:10:29 | btn1_Click | This action is missing an authorization check. |
2+
| Test1/ViewProfile.aspx.cs:14:20:14:36 | btn_delete1_Click | This action is missing an authorization check. |
3+
| Test3/B/EditProfile.aspx.cs:8:20:8:29 | btn1_Click | This action is missing an authorization check. |

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/WebFormsTests/Test1/EditProfile.aspx.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ private void doThings() { }
66

77
private bool isAuthorized() { return false; }
88

9+
// BAD: The class name indicates that this may be an Edit method, but there is no auth check
910
protected void btn1_Click(object sender, EventArgs e) {
1011
doThings();
1112
}
1213

14+
// GOOD: There is a call to isAuthorized
1315
protected void btn2_Click(object sender, EventArgs e) {
1416
if (isAuthorized()) {
1517
doThings();

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/WebFormsTests/Test1/ViewProfile.aspx.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
class ViewProfile : System.Web.UI.Page {
66
private void doThings() { }
77

8+
// GOOD: This method and class name do not indicate a sensitive method.
89
protected void btn_safe_Click(object sender, EventArgs e) {
910
doThings();
1011
}
1112

13+
// BAD: The name indicates a Delete method, but no auth is present.
1214
protected void btn_delete1_Click(object sender, EventArgs e) {
1315
doThings();
1416
}
1517

18+
// GOOD: User.IsInRole is checked.
1619
protected void btn_delete2_Click(object sender, EventArgs e) {
1720
if (User.IsInRole("admin")) {
1821
doThings();

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/WebFormsTests/Test2/EditProfile.aspx.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class EditProfile2 : System.Web.UI.Page {
55
private void doThings() { }
66

7+
// GOOD: The Web.config file specifies auth for this path.
78
protected void btn1_Click(object sender, EventArgs e) {
89
doThings();
910
}

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/WebFormsTests/Test3/A/EditProfile.aspx.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class EditProfile3 : System.Web.UI.Page {
55
private void doThings() { }
66

7+
// GOOD: This is covered by the Web.config's location tag referring to A
78
protected void btn1_Click(object sender, EventArgs e) {
89
doThings();
910
}

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/WebFormsTests/Test3/B/EditProfile.aspx.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class EditProfile4 : System.Web.UI.Page {
55
private void doThings() { }
66

7+
// BAD: The Web.config file does not specify auth for this path.
78
protected void btn1_Click(object sender, EventArgs e) {
89
doThings();
910
}

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/WebFormsTests/Test3/C/EditProfile.aspx.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class EditProfile5 : System.Web.UI.Page {
55
private void doThings() { }
66

7+
// GOOD: The Web.config file specifies auth for the path Virtual, which is mapped to C in Global.asax
78
protected void btn1_Click(object sender, EventArgs e) {
89
doThings();
910
}

0 commit comments

Comments
 (0)