@@ -12,8 +12,8 @@ private import Response::Private as RP
12
12
* A callable node that takes a single argument and, if it has a method name,
13
13
* is called "call".
14
14
*/
15
- private class PotentialCallNode extends DataFlow:: CallableNode {
16
- PotentialCallNode ( ) {
15
+ private class PotentialRequestHandler extends DataFlow:: CallableNode {
16
+ PotentialRequestHandler ( ) {
17
17
this .getNumberOfParameters ( ) = 1 and
18
18
(
19
19
this .( DataFlow:: MethodNode ) .getMethodName ( ) = "call"
@@ -32,26 +32,14 @@ private class PotentialCallNode extends DataFlow::CallableNode {
32
32
}
33
33
}
34
34
35
- /**
36
- * A callable node that looks like it implements the rack specification.
37
- */
38
- private class CallNode extends PotentialCallNode {
39
- private RP:: PotentialResponseNode resp ;
40
-
41
- CallNode ( ) { resp = trackRackResponse ( this ) }
42
-
43
- /** Gets a response returned from a request to this application. */
44
- RP:: PotentialResponseNode getAResponse ( ) { result = resp }
45
- }
46
-
47
- private DataFlow:: LocalSourceNode trackRackResponse ( TypeBackTracker t , PotentialCallNode call ) {
35
+ private DataFlow:: LocalSourceNode trackRackResponse ( TypeBackTracker t , PotentialRequestHandler call ) {
48
36
t .start ( ) and
49
37
result = call .getAReturnNode ( ) .getALocalSource ( )
50
38
or
51
39
exists ( TypeBackTracker t2 | result = trackRackResponse ( t2 , call ) .backtrack ( t2 , t ) )
52
40
}
53
41
54
- private RP:: PotentialResponseNode trackRackResponse ( PotentialCallNode call ) {
42
+ private RP:: PotentialResponseNode trackRackResponse ( PotentialRequestHandler call ) {
55
43
result = trackRackResponse ( TypeBackTracker:: end ( ) , call )
56
44
}
57
45
@@ -66,7 +54,7 @@ module App {
66
54
* (traditionally called `env`) and returns a rack-compatible response.
67
55
*/
68
56
deprecated class AppCandidate extends DataFlow:: ClassNode {
69
- private CallNode call ;
57
+ private RequestHandler call ;
70
58
private RP:: PotentialResponseNode resp ;
71
59
72
60
AppCandidate ( ) {
@@ -84,64 +72,18 @@ module App {
84
72
RP:: PotentialResponseNode getResponse ( ) { result = resp }
85
73
}
86
74
87
- private newtype TApp =
88
- TClassApp ( DataFlow:: ClassNode cn , CallNode call ) or
89
- TAnonymousApp ( CallNode call )
90
-
91
75
/**
92
- * A rack application. This is either some object that responds to `call`
93
- * taking a single argument and returns a rack response, or a lambda or
94
- * proc that takes a single `env` argument and returns a rack response.
76
+ * A callable node that looks like it implements the rack specification.
95
77
*/
96
- abstract class RackApplication extends TApp {
97
- /** Gets a textual representation of this element. */
98
- string toString ( ) { result = "Rack application" }
99
-
100
- /** Gets the `DataFlow::CallableNode` that will handle requests to this app. */
101
- abstract CallNode getCall ( ) ;
102
-
103
- /** Gets a response returned from a request to this app. */
104
- RP:: PotentialResponseNode getAResponse ( ) { result = this .getCall ( ) .getAResponse ( ) }
105
-
106
- /** Gets the `env` parameter passed to this app when it handles a request. */
107
- DataFlow:: ParameterNode getEnv ( ) { result = this .getCall ( ) .getParameter ( 0 ) }
108
- }
109
-
110
- /**
111
- * A rack application using a `DataFlow::ClassNode`. The class has either
112
- * an instance method or a singleton method named "call" which takes a
113
- * single `env` argument and returns a rack response.
114
- */
115
- private class ClassRackApplication extends TApp , RackApplication {
116
- private DataFlow:: ClassNode cn ;
117
- private CallNode call ;
118
-
119
- ClassRackApplication ( ) {
120
- this = TClassApp ( cn , call ) and
121
- call = [ cn .getInstanceMethod ( "call" ) , cn .getSingletonMethod ( "call" ) ]
122
- }
123
-
124
- override string toString ( ) { result = "Rack application: " + cn .toString ( ) }
125
-
126
- override CallNode getCall ( ) { result = call }
127
- }
128
-
129
- /**
130
- * A rack application that is either a lambda or a proc, which takes a
131
- * single `env` argument and returns a rack response.
132
- */
133
- private class AnonymousRackApplication extends TApp , RackApplication {
134
- private CallNode call ;
78
+ class RequestHandler extends PotentialRequestHandler {
79
+ private RP:: PotentialResponseNode resp ;
135
80
136
- AnonymousRackApplication ( ) {
137
- this = TAnonymousApp ( call ) and
138
- not exists ( DataFlow:: ClassNode cn |
139
- call = [ cn .getInstanceMethod ( _) , cn .getSingletonMethod ( _) ]
140
- )
141
- }
81
+ RequestHandler ( ) { resp = trackRackResponse ( this ) }
142
82
143
- override string toString ( ) { result = "Rack application: " + call .toString ( ) }
83
+ /** Gets the `env` parameter passed to this request handler. */
84
+ DataFlow:: ParameterNode getEnv ( ) { result = this .getParameter ( 0 ) }
144
85
145
- override CallNode getCall ( ) { result = call }
86
+ /** Gets a response returned from this request handler. */
87
+ RP:: PotentialResponseNode getAResponse ( ) { result = resp }
146
88
}
147
89
}
0 commit comments