Skip to content

Commit c52545f

Browse files
committed
Extracted isMicrosoftAspNetCoreMvcApplication to predicate
1 parent 06d874f commit c52545f

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -249,30 +249,32 @@ private predicate isMicrosoftAspNetCoreMvcAddApplicationPart(MethodCall call) {
249249
}
250250

251251
private predicate isMicrosoftAspNetCoreMvcApplicationPart(Compilation application, Assembly part) {
252-
part = application.getOutputAssembly()
253-
or
254-
exists(AssemblyAttribute attr, StringLiteral assemblyName |
255-
application.getAFileCompiled() = attr.getFile() and
256-
attr.getType()
257-
.hasFullyQualifiedName("Microsoft.AspNetCore.Mvc.ApplicationParts",
258-
"ApplicationPartAttribute") and
259-
assemblyName = attr.getArgument(0) and
260-
assemblyName.getValue() = part.getName()
261-
)
262-
or
263-
exists(MethodCall addPart, PropertyAccess assemblyAccess, TypeofExpr typeOf, Type partType |
264-
application.getAFileCompiled() = addPart.getFile() and
265-
isMicrosoftAspNetCoreMvcAddApplicationPart(addPart) and
266-
assemblyAccess = addPart.getArgumentForName("assembly") and
267-
assemblyAccess.getTarget().hasName("Assembly") and
268-
assemblyAccess.getQualifier() = typeOf and
269-
partType = typeOf.getTypeAccess().getTarget() and
270-
part = getAnAssemblyFor(partType)
252+
isMicrosoftAspNetCoreMvcApplication(application) and
253+
(
254+
part = application.getOutputAssembly()
255+
or
256+
exists(AssemblyAttribute attr, StringLiteral assemblyName |
257+
application.getAFileCompiled() = attr.getFile() and
258+
attr.getType()
259+
.hasFullyQualifiedName("Microsoft.AspNetCore.Mvc.ApplicationParts",
260+
"ApplicationPartAttribute") and
261+
assemblyName = attr.getArgument(0) and
262+
assemblyName.getValue() = part.getName()
263+
)
264+
or
265+
exists(MethodCall addPart, PropertyAccess assemblyAccess, TypeofExpr typeOf, Type partType |
266+
application.getAFileCompiled() = addPart.getFile() and
267+
isMicrosoftAspNetCoreMvcAddApplicationPart(addPart) and
268+
assemblyAccess = addPart.getArgumentForName("assembly") and
269+
assemblyAccess.getTarget().hasName("Assembly") and
270+
assemblyAccess.getQualifier() = typeOf and
271+
partType = typeOf.getTypeAccess().getTarget() and
272+
part = getAnAssemblyFor(partType)
273+
)
271274
)
272275
}
273276

274277
private predicate isInMicrosoftAspNetCoreMvcApplication(Class controller, Compilation application) {
275-
isMicrosoftAspNetCoreMvcApplication(application) and
276278
isMicrosoftAspNetCoreMvcApplicationPart(application, getAnAssemblyFor(controller))
277279
}
278280

0 commit comments

Comments
 (0)