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 {
179
179
* - https://flask.palletsprojects.com/en/2.2.x/api/#flask.json.jsonify
180
180
*/
181
181
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
+ }
183
189
184
190
override DataFlow:: Node getBody ( ) { result in [ this .getArg ( _) , this .getArgByName ( _) ] }
185
191
Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ def html8(): # $requestHandler
67
67
@app .route ("/jsonify" ) # $routeSetup="/jsonify"
68
68
def jsonify_route (): # $requestHandler
69
69
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
+
70
78
resp = jsonify (x , y , z = z ) # $ HttpResponse mimetype=application/json responseBody=x responseBody=y responseBody=z
71
79
return resp # $ SPURIOUS: HttpResponse mimetype=text/html responseBody=resp
72
80
You can’t perform that action at this time.
0 commit comments