mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Add unit tests for webform case with auth in code
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
| Test1/EditProfile.aspx.cs:9:20:9:29 | btn1_Click | This action is missing an authorization check. |
|
||||
| Test1/ViewProfile.aspx.cs:14:20:14:36 | btn_delete1_Click | This action is missing an authorization check. |
|
||||
@@ -0,0 +1 @@
|
||||
Security Features/CWE-285/MissingAccessControl.ql
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
|
||||
class EditProfile : System.Web.UI.Page {
|
||||
private void doThings() { }
|
||||
|
||||
private bool isAuthorized() { return false; }
|
||||
|
||||
protected void btn1_Click(object sender, EventArgs e) {
|
||||
doThings();
|
||||
}
|
||||
|
||||
protected void btn2_Click(object sender, EventArgs e) {
|
||||
if (isAuthorized()) {
|
||||
doThings();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
using System.Web.Security;
|
||||
|
||||
class ViewProfile : System.Web.UI.Page {
|
||||
private void doThings() { }
|
||||
|
||||
public System.Security.Principal.IPrincipal User { get; } // TODO: this should be in the stubs
|
||||
|
||||
protected void btn_safe_Click(object sender, EventArgs e) {
|
||||
doThings();
|
||||
}
|
||||
|
||||
protected void btn_delete1_Click(object sender, EventArgs e) {
|
||||
doThings();
|
||||
}
|
||||
|
||||
protected void btn_delete2_Click(object sender, EventArgs e) {
|
||||
if (User.IsInRole("admin")) {
|
||||
doThings();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: /r:System.Runtime.Extensions.dll /r:System.Collections.Specialized.dll ${testdir}/../../../../resources/stubs/System.Web.cs
|
||||
Reference in New Issue
Block a user