11import python
22import semmle.python.web.Http
33
4-
54/** The falcon API class */
6- ClassValue theFalconAPIClass ( ) {
7- result = Value:: named ( "falcon.API" )
8- }
5+ ClassValue theFalconAPIClass ( ) { result = Value:: named ( "falcon.API" ) }
96
10-
11- /** Holds if `route` is routed to `resource`
12- */
7+ /** Holds if `route` is routed to `resource` */
138private predicate api_route ( CallNode route_call , ControlFlowNode route , ClassValue resource ) {
149 route_call .getFunction ( ) .( AttrNode ) .getObject ( "add_route" ) .pointsTo ( ) .getClass ( ) = theFalconAPIClass ( ) and
1510 route_call .getArg ( 0 ) = route and
@@ -21,10 +16,7 @@ private predicate route(FalconRoute route, Function target, string funcname) {
2116}
2217
2318class FalconRoute extends ControlFlowNode {
24-
25- FalconRoute ( ) {
26- api_route ( this , _, _)
27- }
19+ FalconRoute ( ) { api_route ( this , _, _) }
2820
2921 string getUrl ( ) {
3022 exists ( StrConst url |
@@ -33,36 +25,19 @@ class FalconRoute extends ControlFlowNode {
3325 )
3426 }
3527
36- ClassValue getResourceClass ( ) {
37- api_route ( this , _, result )
38- }
39-
40- FalconHandlerFunction getHandlerFunction ( string method ) {
41- route ( this , result , method )
42- }
28+ ClassValue getResourceClass ( ) { api_route ( this , _, result ) }
4329
30+ FalconHandlerFunction getHandlerFunction ( string method ) { route ( this , result , method ) }
4431}
4532
4633class FalconHandlerFunction extends Function {
34+ FalconHandlerFunction ( ) { route ( _, this , _) }
4735
48- FalconHandlerFunction ( ) {
49- route ( _, this , _)
50- }
51-
52- private string methodName ( ) {
53- route ( _, this , result )
54- }
36+ private string methodName ( ) { route ( _, this , result ) }
5537
56- string getMethod ( ) {
57- result = this .methodName ( ) .toUpperCase ( )
58- }
38+ string getMethod ( ) { result = this .methodName ( ) .toUpperCase ( ) }
5939
60- Parameter getRequest ( ) {
61- result = this .getArg ( 1 )
62- }
63-
64- Parameter getResponse ( ) {
65- result = this .getArg ( 2 )
66- }
40+ Parameter getRequest ( ) { result = this .getArg ( 1 ) }
6741
42+ Parameter getResponse ( ) { result = this .getArg ( 2 ) }
6843}
0 commit comments