File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
src/semmle/python/frameworks
test/library-tests/frameworks/twisted Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -226,4 +226,33 @@ private module Twisted {
226
226
227
227
override string getMimetypeDefault ( ) { result = "text/html" }
228
228
}
229
+
230
+ /**
231
+ * A call to the `redirect` function on a twisted request.
232
+ *
233
+ * See https://twistedmatrix.com/documents/21.2.0/api/twisted.web.http.Request.html#redirect
234
+ */
235
+ class TwistedRequestRedirectCall extends HTTP:: Server:: HttpRedirectResponse:: Range ,
236
+ DataFlow:: CallCfgNode {
237
+ TwistedRequestRedirectCall ( ) {
238
+ // TODO: When we have tools that make it easy, model these properly to handle
239
+ // `meth = obj.meth; meth()`. Until then, we'll use this more syntactic approach
240
+ // (since it allows us to at least capture the most common cases).
241
+ exists ( DataFlow:: AttrRead read |
242
+ this .getFunction ( ) = read and
243
+ read .getObject ( ) = Request:: instance ( ) and
244
+ read .getAttributeName ( ) = "redirect"
245
+ )
246
+ }
247
+
248
+ override DataFlow:: Node getBody ( ) { none ( ) }
249
+
250
+ override DataFlow:: Node getRedirectLocation ( ) {
251
+ result .asCfgNode ( ) in [ node .getArg ( 0 ) , node .getArgByName ( "url" ) ]
252
+ }
253
+
254
+ override DataFlow:: Node getMimetypeOrContentTypeArg ( ) { none ( ) }
255
+
256
+ override string getMimetypeDefault ( ) { result = "text/html" }
257
+ }
229
258
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def render(self, request: Request): # $ requestHandler
38
38
39
39
class Redirect (Resource ):
40
40
def render_GET (self , request : Request ): # $ requestHandler
41
- request .redirect ("/new-location" ) # $ MISSING: HttpRedirectResponse
41
+ request .redirect ("/new-location" ) # $ HttpRedirectResponse redirectLocation="/new-location" HttpResponse mimetype=text/html
42
42
# By default, this `hello` output is not returned... not even when
43
43
# requested with curl.
44
44
return b"hello" # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=b"hello"
You can’t perform that action at this time.
0 commit comments