Skip to content

Commit 105462a

Browse files
JarLobmichaelnebel
authored andcommitted
Extend aspnetcore controller definition
1 parent 0581b91 commit 105462a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ class MicrosoftAspNetCoreMvcNonActionAttribute extends MicrosoftAspNetCoreMvcAtt
6262
MicrosoftAspNetCoreMvcNonActionAttribute() { this.getType().hasName("NonActionAttribute") }
6363
}
6464

65+
class MicrosoftAspNetCoreMvcNonControllerAttribute extends MicrosoftAspNetCoreMvcAttribute {
66+
MicrosoftAspNetCoreMvcNonControllerAttribute() { getType().hasName("NonControllerAttribute") }
67+
}
68+
69+
class MicrosoftAspNetCoreMvcControllerAttribute extends MicrosoftAspNetCoreMvcAttribute {
70+
MicrosoftAspNetCoreMvcControllerAttribute() { getType().hasName("ControllerAttribute") }
71+
}
72+
6573
/** The `Microsoft.AspNetCore.Antiforgery` namespace. */
6674
class MicrosoftAspNetCoreAntiforgeryNamespace extends Namespace {
6775
MicrosoftAspNetCoreAntiforgeryNamespace() {
@@ -185,7 +193,12 @@ class MicrosoftAspNetCoreMvcControllerBaseClass extends Class {
185193
/** A subtype of `Microsoft.AspNetCore.Mvc.Controller` or `Microsoft.AspNetCore.Mvc.ControllerBase`. */
186194
class MicrosoftAspNetCoreMvcController extends Class {
187195
MicrosoftAspNetCoreMvcController() {
188-
this.getABaseType*() instanceof MicrosoftAspNetCoreMvcControllerBaseClass
196+
(
197+
getABaseType*() instanceof MicrosoftAspNetCoreMvcControllerBaseClass or
198+
getABaseType*().hasName("%Controller") or
199+
getABaseType*().getAnAttribute() instanceof MicrosoftAspNetCoreMvcControllerAttribute
200+
) and
201+
not getABaseType*().getAnAttribute() instanceof MicrosoftAspNetCoreMvcNonControllerAttribute
189202
}
190203

191204
/** Gets an action method for this controller. */

0 commit comments

Comments
 (0)