@@ -34,7 +34,7 @@ private module FlaskModel {
3434 * WARNING: Only holds for a few predefined attributes.
3535 */
3636 private DataFlow:: Node flask_attr ( DataFlow:: TypeTracker t , string attr_name ) {
37- attr_name in [ "request" , "make_response" , "Response" , "views" ] and
37+ attr_name in [ "request" , "make_response" , "Response" , "views" , "redirect" ] and
3838 (
3939 t .start ( ) and
4040 result = DataFlow:: importNode ( "flask" + "." + attr_name )
@@ -669,4 +669,31 @@ private module FlaskModel {
669669
670670 override string getMimetypeDefault ( ) { result = "text/html" }
671671 }
672+
673+ /**
674+ * A call to the `flask.redirect` function.
675+ *
676+ * See https://flask.palletsprojects.com/en/1.1.x/api/#flask.redirect
677+ */
678+ private class FlaskRedirectCall extends HTTP:: Server:: HttpRedirectResponse:: Range ,
679+ DataFlow:: CfgNode {
680+ override CallNode node ;
681+
682+ FlaskRedirectCall ( ) { node .getFunction ( ) = flask_attr ( "redirect" ) .asCfgNode ( ) }
683+
684+ override DataFlow:: Node getRedirectLocation ( ) {
685+ result .asCfgNode ( ) in [ node .getArg ( 0 ) , node .getArgByName ( "location" ) ]
686+ }
687+
688+ override DataFlow:: Node getBody ( ) { none ( ) }
689+
690+ override DataFlow:: Node getMimetypeOrContentTypeArg ( ) { none ( ) }
691+
692+ override string getMimetypeDefault ( ) {
693+ // note that while you're not able to set content yourself, the function will
694+ // actually fill out some default content, that is served with mimetype
695+ // `text/html`.
696+ result = "text/html"
697+ }
698+ }
672699}
0 commit comments