@@ -15,7 +15,10 @@ abstract class ActionMethod extends Method {
15
15
}
16
16
17
17
predicate needsAuth ( ) {
18
- this .getADescription ( ) .toLowerCase ( ) .regexpMatch ( ".*(edit|delete|modify|admin|superuser).*" )
18
+ this .getADescription ( )
19
+ .regexpReplaceAll ( "([a-z])([A-Z])" , "$1_$2" )
20
+ .toLowerCase ( )
21
+ .regexpMatch ( ".*(edit|delete|modify|admin|superuser).*" )
19
22
}
20
23
21
24
Callable getAnAuthorizingCallable ( ) { result = this }
@@ -40,6 +43,38 @@ private class WebFormActionMethod extends ActionMethod {
40
43
result .getDeclaringType ( ) = this .getDeclaringType ( ) and
41
44
result .getName ( ) = "Page_Load"
42
45
}
46
+
47
+ override string getARoute ( ) {
48
+ exists ( string physicalRoute | physicalRoute = super .getARoute ( ) |
49
+ result = physicalRoute
50
+ or
51
+ exists ( string absolutePhysical |
52
+ virtualRouteMapping ( result , absolutePhysical ) and
53
+ physicalRouteMatches ( absolutePhysical , physicalRoute )
54
+ )
55
+ )
56
+ }
57
+ }
58
+
59
+ private predicate virtualRouteMapping ( string virtualRoute , string physicalRoute ) {
60
+ exists ( MethodCall mapPageRouteCall , StringLiteral virtualLit , StringLiteral physicalLit |
61
+ mapPageRouteCall
62
+ .getTarget ( )
63
+ .hasQualifiedName ( "System.Web.Routing" , "RouteCollection" , "MapPageRoute" ) and
64
+ virtualLit = mapPageRouteCall .getArgument ( 1 ) and
65
+ physicalLit = mapPageRouteCall .getArgument ( 2 ) and
66
+ virtualLit .getValue ( ) = virtualRoute and
67
+ physicalLit .getValue ( ) = physicalRoute
68
+ // physicalRouteMatches(physicalLit.getValue(), physicalRoute)
69
+ )
70
+ }
71
+
72
+ bindingset [ route, actual]
73
+ private predicate physicalRouteMatches ( string route , string actual ) {
74
+ route = actual
75
+ or
76
+ route .charAt ( 0 ) = "~" and
77
+ exists ( string dir | actual = dir + route .substring ( 1 , route .length ( ) ) + ".cs" )
43
78
}
44
79
45
80
/** An expression that indicates that some authorization/authentication check is being performed. */
0 commit comments