@@ -21,13 +21,18 @@ private import semmle.python.frameworks.Stdlib
21
21
module Pyramid {
22
22
/** Provides models for pyramid View callables. */
23
23
module View {
24
+ /** A dataflow node that sets up a route on a server using the Pyramid framework. */
25
+ abstract private class PyramidRouteSetup extends Http:: Server:: RouteSetup:: Range {
26
+ override string getFramework ( ) { result = "Pyramid" }
27
+ }
28
+
24
29
/**
25
- * A callable that could be used as a pyramid view callable .
30
+ * A Pyramid view callable, that handles incoming requests .
26
31
*/
27
- private class PotentialViewCallable extends Function {
28
- PotentialViewCallable ( ) { this . getPositionalParameterCount ( ) in [ 1 , 2 ] }
32
+ class ViewCallable extends Function {
33
+ ViewCallable ( ) { this = any ( PyramidRouteSetup rs ) . getARequestHandler ( ) }
29
34
30
- /** Gets the `request` parameter of this view callable. */
35
+ /** Gets the `request` parameter of this callable. */
31
36
Parameter getRequestParameter ( ) {
32
37
this .getPositionalParameterCount ( ) = 1 and
33
38
result = this .getArg ( 0 )
@@ -37,18 +42,6 @@ module Pyramid {
37
42
}
38
43
}
39
44
40
- /** A dataflow node that sets up a route on a server using the Pyramid framework. */
41
- abstract private class PyramidRouteSetup extends Http:: Server:: RouteSetup:: Range {
42
- override string getFramework ( ) { result = "Pyramid" }
43
- }
44
-
45
- /**
46
- * A Pyramid view callable, that handles incoming requests.
47
- */
48
- class ViewCallable extends PotentialViewCallable {
49
- ViewCallable ( ) { this = any ( PyramidRouteSetup rs ) .getARequestHandler ( ) }
50
- }
51
-
52
45
/** A pyramid route setup using the `pyramid.view.view_config` decorator. */
53
46
private class DecoratorSetup extends PyramidRouteSetup {
54
47
DecoratorSetup ( ) {
@@ -92,15 +85,16 @@ module Pyramid {
92
85
/** Gets a reference to an instance of `pyramid.config.Configurator`. */
93
86
DataFlow:: Node instance ( ) { instance ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result ) }
94
87
95
- /** Gets a call to the `add_view` method of an instance of `pyramid.config.Configurator`. */
88
+ /** A call to the `add_view` method of an instance of `pyramid.config.Configurator`. */
96
89
class AddViewCall extends DataFlow:: MethodCallNode {
97
90
AddViewCall ( ) { this .calls ( instance ( ) , "add_view" ) }
98
91
92
+ /** Gets the `view` argument of this call. */
99
93
DataFlow:: Node getViewArg ( ) { result = [ this .getArg ( 0 ) , this .getArgByName ( "view" ) ] }
100
94
}
101
95
}
102
96
103
- /** Provides modelling for pyramid requests. */
97
+ /** Provides modeling for pyramid requests. */
104
98
module Request {
105
99
/**
106
100
* A source of instances of `pyramid.request.Request`, extend this class to model new instances.
@@ -167,7 +161,7 @@ module Pyramid {
167
161
}
168
162
}
169
163
170
- /** Provides modelling for pyramid responses. */
164
+ /** Provides modeling for pyramid responses. */
171
165
module Response {
172
166
/** A response returned by a view callable. */
173
167
private class PyramidReturnResponse extends Http:: Server:: HttpResponse:: Range {
@@ -287,7 +281,7 @@ module Pyramid {
287
281
] )
288
282
}
289
283
290
- /** Gets a call to a pyramid HTTP exception class that represents an HTTP redirect response. */
284
+ /** A call to a pyramid HTTP exception class that represents an HTTP redirect response. */
291
285
class PyramidRedirect extends Http:: Server:: HttpRedirectResponse:: Range , DataFlow:: CallCfgNode {
292
286
PyramidRedirect ( ) { this = classRef ( ) .getACall ( ) }
293
287
0 commit comments