Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ad43f3

Browse files
committed
Python: Add flask xss examples to flask tests
1 parent 8476bc7 commit 3ad43f3

5 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| / | Function hello |
22
| /dangerous | Function dangerous |
33
| /dangerous-with-cfg-split | Function dangerous2 |
4+
| /safe | Function safe |
45
| /the/ | Function get |
6+
| /unsafe | Function unsafe |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
| test.py:29 | Attribute() | externally controlled string |
33
| test.py:35 | Subscript | externally controlled string |
44
| test.py:36 | None | externally controlled string |
5+
| test.py:41 | BinaryExpr | externally controlled string |
6+
| test.py:41 | make_response() | externally controlled string |
7+
| test.py:46 | BinaryExpr | externally controlled string |
8+
| test.py:46 | make_response() | externally controlled string |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
| test.py:29 | Attribute | {externally controlled string} |
33
| test.py:33 | Attribute | {externally controlled string} |
44
| test.py:35 | Attribute | {externally controlled string} |
5+
| test.py:40 | Attribute | {externally controlled string} |
6+
| test.py:45 | Attribute | {externally controlled string} |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@
66
| test.py:33 | Subscript | externally controlled string |
77
| test.py:35 | Attribute | {externally controlled string} |
88
| test.py:35 | Subscript | externally controlled string |
9+
| test.py:40 | Attribute | {externally controlled string} |
10+
| test.py:40 | Attribute() | externally controlled string |
11+
| test.py:41 | BinaryExpr | externally controlled string |
12+
| test.py:41 | first_name | externally controlled string |
13+
| test.py:41 | make_response() | flask.Response |
14+
| test.py:45 | Attribute | {externally controlled string} |
15+
| test.py:45 | Attribute() | externally controlled string |
16+
| test.py:46 | first_name | externally controlled string |
17+
| test.py:46 | make_response() | flask.Response |

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import flask
22

3-
from flask import Flask, request
3+
from flask import Flask, request, make_response
44
app = Flask(__name__)
55

66
@app.route("/")
@@ -34,3 +34,13 @@ def dangerous2():
3434
if request.method == "POST":
3535
return request.form['param1']
3636
return None
37+
38+
@app.route('/unsafe')
39+
def unsafe():
40+
first_name = request.args.get('name', '')
41+
return make_response("Your name is " + first_name)
42+
43+
@app.route('/safe')
44+
def safe():
45+
first_name = request.args.get('name', '')
46+
return make_response("Your name is " + escape(first_name))

0 commit comments

Comments
 (0)