Skip to content

Commit 1b6e7f9

Browse files
Add unit tests for webform case with auth in code
1 parent 57b3b2b commit 1b6e7f9

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Test1/EditProfile.aspx.cs:9:20:9: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. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security Features/CWE-285/MissingAccessControl.ql
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Web.UI;
3+
4+
class EditProfile : System.Web.UI.Page {
5+
private void doThings() { }
6+
7+
private bool isAuthorized() { return false; }
8+
9+
protected void btn1_Click(object sender, EventArgs e) {
10+
doThings();
11+
}
12+
13+
protected void btn2_Click(object sender, EventArgs e) {
14+
if (isAuthorized()) {
15+
doThings();
16+
}
17+
}
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Web.UI;
3+
using System.Web.Security;
4+
5+
class ViewProfile : System.Web.UI.Page {
6+
private void doThings() { }
7+
8+
public System.Security.Principal.IPrincipal User { get; } // TODO: this should be in the stubs
9+
10+
protected void btn_safe_Click(object sender, EventArgs e) {
11+
doThings();
12+
}
13+
14+
protected void btn_delete1_Click(object sender, EventArgs e) {
15+
doThings();
16+
}
17+
18+
protected void btn_delete2_Click(object sender, EventArgs e) {
19+
if (User.IsInRole("admin")) {
20+
doThings();
21+
}
22+
}
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: /r:System.Runtime.Extensions.dll /r:System.Collections.Specialized.dll ${testdir}/../../../../resources/stubs/System.Web.cs

0 commit comments

Comments
 (0)