Skip to content

Commit 7d5e35a

Browse files
committed
Python: Expand flask tests to use "variable rules"
which is what flask calls them. wildcard rules in bottle, django doesn't even give them a proper term :(
1 parent 8ce9c9d commit 7d5e35a

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

python/ql/test/library-tests/web/flask/HttpResponseSinks.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@
66
| test.py:41:26:41:53 | flask.response.argument | externally controlled string |
77
| test.py:46:12:46:62 | flask.routed.response | externally controlled string |
88
| test.py:46:26:46:61 | flask.response.argument | externally controlled string |
9+
| test.py:50:12:50:48 | flask.routed.response | externally controlled string |
10+
| test.py:50:26:50:47 | flask.response.argument | externally controlled string |
11+
| test.py:54:12:54:53 | flask.routed.response | externally controlled string |
12+
| test.py:54:26:54:52 | flask.response.argument | externally controlled string |
13+
| test.py:60:12:60:62 | flask.routed.response | externally controlled string |
14+
| test.py:60:26:60:61 | flask.response.argument | externally controlled string |
15+
| test.py:64:12:64:58 | flask.routed.response | externally controlled string |
16+
| test.py:64:26:64:57 | flask.response.argument | externally controlled string |
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
| / | Function hello |
1+
| / | Function hello_world |
2+
| /complex/<string(length=2):lang_code> | Function complex |
23
| /dangerous | Function dangerous |
34
| /dangerous-with-cfg-split | Function dangerous2 |
5+
| /foo/<path:subpath> | Function foo |
6+
| /hello/<name> | Function hello |
7+
| /multiple/bar/<bar> | Function multiple |
48
| /safe | Function safe |
59
| /the/ | Function get |
610
| /unsafe | Function unsafe |

python/ql/test/library-tests/web/flask/Taint.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
| test.py:45 | Attribute() | externally controlled string |
1616
| test.py:46 | first_name | externally controlled string |
1717
| test.py:46 | make_response() | flask.Response |
18+
| test.py:50 | make_response() | flask.Response |
19+
| test.py:54 | make_response() | flask.Response |
20+
| test.py:60 | make_response() | flask.Response |
21+
| test.py:64 | make_response() | flask.Response |

python/ql/test/library-tests/web/flask/test.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
app = Flask(__name__)
55

66
@app.route("/")
7-
def hello():
7+
def hello_world():
88
return "Hello World!"
99

1010
from flask.views import MethodView
@@ -44,3 +44,24 @@ def unsafe():
4444
def safe():
4545
first_name = request.args.get('name', '')
4646
return make_response("Your name is " + escape(first_name))
47+
48+
@app.route('/hello/<name>')
49+
def hello(name):
50+
return make_response("Your name is " + name)
51+
52+
@app.route('/foo/<path:subpath>')
53+
def foo(subpath):
54+
return make_response("The subpath is " + subpath)
55+
56+
@app.route('/multiple/') # TODO: not recognized as route
57+
@app.route('/multiple/foo/<foo>') # TODO: not recognized as route
58+
@app.route('/multiple/bar/<bar>')
59+
def multiple(foo=None, bar=None):
60+
return make_response("foo={!r} bar={!r}".format(foo, bar))
61+
62+
@app.route('/complex/<string(length=2):lang_code>')
63+
def complex(lang_code):
64+
return make_response("lang_code {}".format(lang_code))
65+
66+
if __name__ == "__main__":
67+
app.run(debug=True)

0 commit comments

Comments
 (0)