File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
lib/semmle/python/frameworks
test/library-tests/frameworks/flask Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,13 @@ module Flask {
179179 * - https://flask.palletsprojects.com/en/2.2.x/api/#flask.json.jsonify
180180 */
181181 private class FlaskJsonifyCall extends InstanceSource , DataFlow:: CallCfgNode {
182- FlaskJsonifyCall ( ) { this = API:: moduleImport ( "flask" ) .getMember ( "jsonify" ) .getACall ( ) }
182+ FlaskJsonifyCall ( ) {
183+ this = API:: moduleImport ( "flask" ) .getMember ( "jsonify" ) .getACall ( )
184+ or
185+ this = API:: moduleImport ( "flask" ) .getMember ( "json" ) .getMember ( "jsonify" ) .getACall ( )
186+ or
187+ this = FlaskApp:: instance ( ) .getMember ( "json" ) .getMember ( "response" ) .getACall ( )
188+ }
183189
184190 override DataFlow:: Node getBody ( ) { result in [ this .getArg ( _) , this .getArgByName ( _) ] }
185191
Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ def html8(): # $requestHandler
6767@app .route ("/jsonify" ) # $routeSetup="/jsonify"
6868def jsonify_route (): # $requestHandler
6969 x = "x" ; y = "y" ; z = "z"
70+ if True :
71+ import flask .json
72+ resp = flask .json .jsonify (x , y , z = z ) # $HttpResponse mimetype=application/json responseBody=x responseBody=y responseBody=z
73+ assert resp .mimetype == "application/json"
74+
75+ resp = app .json .response (x , y , z = z ) # $HttpResponse mimetype=application/json responseBody=x responseBody=y responseBody=z
76+ assert resp .mimetype == "application/json"
77+
7078 resp = jsonify (x , y , z = z ) # $ HttpResponse mimetype=application/json responseBody=x responseBody=y responseBody=z
7179 return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
7280
You can’t perform that action at this time.
0 commit comments