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 {
226226
227227 override string getMimetypeDefault ( ) { result = "text/html" }
228228 }
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+ }
229258}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def render(self, request: Request): # $ requestHandler
3838
3939class Redirect (Resource ):
4040 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
4242 # By default, this `hello` output is not returned... not even when
4343 # requested with curl.
4444 return b"hello" # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=b"hello"
You can’t perform that action at this time.
0 commit comments