@@ -65,10 +65,13 @@ private class ViewCall extends MethodCall {
6565}
6666
6767/** A compiler-generated Razor page. */
68- class RazorPage extends Class {
68+ class RazorPageClass extends Class {
6969 AssemblyAttribute attr ;
7070
71- RazorPage ( ) {
71+ RazorPageClass ( ) {
72+ this .getBaseClass ( )
73+ .getUnboundDeclaration ( )
74+ .hasQualifiedName ( "Microsoft.AspNetCore.Mvc.Razor" , "RazorPage<>" ) and
7275 attr .getFile ( ) = this .getFile ( ) and
7376 attr .getType ( )
7477 .hasQualifiedName ( "Microsoft.AspNetCore.Razor.Hosting" , "RazorCompiledItemAttribute" )
@@ -83,7 +86,7 @@ class RazorPage extends Class {
8386
8487private class ViewCallFlowStep extends TaintTracking:: AdditionalTaintStep {
8588 override predicate step ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
86- exists ( ViewCall vc , RazorPage rp , PropertyAccess modelProp |
89+ exists ( ViewCall vc , RazorPageClass rp , PropertyAccess modelProp |
8790 viewCallRefersToPage ( vc , rp ) and
8891 node1 .asExpr ( ) = vc .getModelArgument ( ) and
8992 node2 .asExpr ( ) = modelProp and
@@ -93,23 +96,24 @@ private class ViewCallFlowStep extends TaintTracking::AdditionalTaintStep {
9396 }
9497}
9598
96- private predicate viewCallRefersToPage ( ViewCall vc , RazorPage rp ) {
99+ private predicate viewCallRefersToPage ( ViewCall vc , RazorPageClass rp ) {
97100 viewCallRefersToPageAbsolute ( vc , rp ) or
98101 viewCallRefersToPageRelative ( vc , rp )
99102}
100103
101- private predicate viewCallRefersToPageAbsolute ( ViewCall vc , RazorPage rp ) {
104+ private predicate viewCallRefersToPageAbsolute ( ViewCall vc , RazorPageClass rp ) {
102105 [ "/" , "" ] + vc .getNameArgument ( ) = [ "" , "~" ] + rp .getSourceFilepath ( )
103106}
104107
105- private predicate viewCallRefersToPageRelative ( ViewCall vc , RazorPage rp ) {
106- [ "" , "~" ] + rp .getSourceFilepath ( ) =
107- min ( int i , RelativeViewCallFilepath fp |
108- fp .hasViewCallWithIndex ( vc , i ) and
109- exists ( RazorPage rp2 | [ "" , "~" ] + rp2 .getSourceFilepath ( ) = fp .getNormalizedPath ( ) )
110- |
111- fp .getNormalizedPath ( ) order by i
112- )
108+ private predicate viewCallRefersToPageRelative ( ViewCall vc , RazorPageClass rp ) {
109+ rp = min ( int i , RazorPageClass rp2 | matchesViewCallWithIndex ( vc , rp2 , i ) | rp2 order by i )
110+ }
111+
112+ private predicate matchesViewCallWithIndex ( ViewCall vc , RazorPageClass rp , int i ) {
113+ exists ( RelativeViewCallFilepath fp |
114+ fp .hasViewCallWithIndex ( vc , i ) and
115+ fp .getNormalizedPath ( ) = [ "" , "~" ] + rp .getSourceFilepath ( )
116+ )
113117}
114118
115119/** Gets the `i`th template for view discovery. */
0 commit comments