@@ -41,36 +41,28 @@ private module Twisted {
41
41
// TODO: This doesn't handle attribute assignment. Should be OK, but analysis is not as complete as with
42
42
// points-to and `.lookup`, which would handle `post = my_post_handler` inside class def
43
43
result = this .getAMethod ( ) and
44
- resourceMethodRequestParamIndex ( result .getName ( ) , _ )
44
+ exists ( getRequestParamIndex ( result .getName ( ) ) )
45
45
}
46
46
}
47
47
48
48
/**
49
- * Holds if the request parameter is supposed to be at index `requestParamIndex` for
50
- * the method named `methodName` in `twisted.web.resource.Resource`.
49
+ * Gets the index the request parameter is supposed to be at for the method named
50
+ * `methodName` in a `twisted.web.resource.Resource` subclass .
51
51
*/
52
52
bindingset [ methodName]
53
- private predicate resourceMethodRequestParamIndex ( string methodName , int requestParamIndex ) {
54
- methodName .matches ( "render_%" ) and requestParamIndex = 1
53
+ private int getRequestParamIndex ( string methodName ) {
54
+ methodName .matches ( "render_%" ) and result = 1
55
55
or
56
- methodName in [ "render" , "listDynamicEntities" , "getChildForRequest" ] and requestParamIndex = 1
56
+ methodName in [ "render" , "listDynamicEntities" , "getChildForRequest" ] and result = 1
57
57
or
58
- methodName = [ "getDynamicEntity" , "getChild" , "getChildWithDefault" ] and requestParamIndex = 2
58
+ methodName = [ "getDynamicEntity" , "getChild" , "getChildWithDefault" ] and result = 2
59
59
}
60
60
61
61
/** A method that handles incoming requests, on a `twisted.web.resource.Resource` subclass. */
62
62
class TwistedResourceRequestHandler extends HTTP:: Server:: RequestHandler:: Range {
63
- TwistedResourceRequestHandler ( ) {
64
- any ( TwistedResourceSubclass cls ) .getAMethod ( ) = this and
65
- resourceMethodRequestParamIndex ( this .getName ( ) , _)
66
- }
63
+ TwistedResourceRequestHandler ( ) { this = any ( TwistedResourceSubclass cls ) .getARequestHandler ( ) }
67
64
68
- Parameter getRequestParameter ( ) {
69
- exists ( int i |
70
- resourceMethodRequestParamIndex ( this .getName ( ) , i ) and
71
- result = this .getArg ( i )
72
- )
73
- }
65
+ Parameter getRequestParameter ( ) { result = this .getArg ( getRequestParamIndex ( this .getName ( ) ) ) }
74
66
75
67
override Parameter getARoutedParameter ( ) { none ( ) }
76
68
0 commit comments