11import python
2-
32import semmle.python.security.TaintTracking
43
54private ClassValue theTwistedHttpRequestClass ( ) {
@@ -10,9 +9,7 @@ private ClassValue theTwistedHttpResourceClass() {
109 result = Value:: named ( "twisted.web.resource.Resource" )
1110}
1211
13- ClassValue aTwistedRequestHandlerClass ( ) {
14- result .getABaseType + ( ) = theTwistedHttpResourceClass ( )
15- }
12+ ClassValue aTwistedRequestHandlerClass ( ) { result .getABaseType + ( ) = theTwistedHttpResourceClass ( ) }
1613
1714FunctionValue getTwistedRequestHandlerMethod ( string name ) {
1815 result = aTwistedRequestHandlerClass ( ) .declaredAttribute ( name )
@@ -24,29 +21,32 @@ predicate isKnownRequestHandlerMethodName(string name) {
2421 name .matches ( "render_%" )
2522}
2623
27- /** Holds if `node` is likely to refer to an instance of the twisted
24+ /**
25+ * Holds if `node` is likely to refer to an instance of the twisted
2826 * `Request` class.
2927 */
3028predicate isTwistedRequestInstance ( NameNode node ) {
3129 node .pointsTo ( ) .getClass ( ) = theTwistedHttpRequestClass ( )
3230 or
33- /* In points-to analysis cannot infer that a given object is an instance of
31+ /*
32+ * In points-to analysis cannot infer that a given object is an instance of
3433 * the `twisted.web.http.Request` class, we also include any parameter
3534 * called `request` that appears inside a subclass of a request handler
3635 * class, and the appropriate arguments of known request handler methods.
3736 */
37+
3838 exists ( Function func | func = node .getScope ( ) |
3939 func .getEnclosingScope ( ) = aTwistedRequestHandlerClass ( ) .getScope ( )
4040 ) and
4141 (
42- /* Any parameter called `request` */
43- node .getId ( ) = "request" and
44- node .isParameter ( )
45- or
46- /* Any request parameter of a known request handler method */
47- exists ( Function func | node .getScope ( ) = func |
48- isKnownRequestHandlerMethodName ( func .getName ( ) ) and
49- node .getNode ( ) = func .getArg ( 1 )
42+ /* Any parameter called `request` */
43+ node .getId ( ) = "request" and
44+ node .isParameter ( )
45+ or
46+ /* Any request parameter of a known request handler method */
47+ exists ( Function func | node .getScope ( ) = func |
48+ isKnownRequestHandlerMethodName ( func .getName ( ) ) and
49+ node .getNode ( ) = func .getArg ( 1 )
5050 )
5151 )
5252}
0 commit comments