Skip to content

Commit 853a80b

Browse files
JarLobmichaelnebel
authored andcommitted
filter out Controller suffixed class in non asp.net projects
1 parent 3d281fb commit 853a80b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/AspNetCore.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,16 @@ class MicrosoftAspNetCoreMvcControllerBaseClass extends Class {
194194
}
195195
}
196196

197-
/** A subtype of `Microsoft.AspNetCore.Mvc.Controller` or `Microsoft.AspNetCore.Mvc.ControllerBase`. */
197+
/** A valid ASP.NET Core controller according to https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/actions?view=aspnetcore-3.1 */
198198
class MicrosoftAspNetCoreMvcController extends Class {
199199
MicrosoftAspNetCoreMvcController() {
200+
exists(Assembly a, string name |
201+
a.getName() = name and
202+
(
203+
name = "Microsoft.AspNetCore.Mvc.Core" or
204+
name = "Microsoft.AspNetCore.Mvc.ViewFeatures"
205+
)
206+
) and
200207
(
201208
this.getABaseType*() instanceof MicrosoftAspNetCoreMvcControllerBaseClass or
202209
this.getABaseType*().getName().matches("%Controller") or

0 commit comments

Comments
 (0)