Skip to content

Commit 0cad5ce

Browse files
committed
Python: Expand py/flask-debug tests a bit
1 parent 8262f03 commit 0cad5ce

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

python/ql/test/query-tests/Security/CWE-215/FlaskDebug.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| test.py:25:1:25:20 | ControlFlowNode for Attribute() | A Flask app appears to be run in debug mode. This may allow an attacker to run arbitrary code through the debugger. |
33
| test.py:29:1:29:20 | ControlFlowNode for Attribute() | A Flask app appears to be run in debug mode. This may allow an attacker to run arbitrary code through the debugger. |
44
| test.py:37:1:37:18 | ControlFlowNode for runapp() | A Flask app appears to be run in debug mode. This may allow an attacker to run arbitrary code through the debugger. |
5+
| test.py:42:1:42:35 | ControlFlowNode for Attribute() | A Flask app appears to be run in debug mode. This may allow an attacker to run arbitrary code through the debugger. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALWAYS_TRUE = True

python/ql/test/query-tests/Security/CWE-215/test.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,29 @@ def main():
2222

2323
DEBUG = True
2424

25-
app.run(debug=DEBUG)
25+
app.run(debug=DEBUG) # NOT OK
2626

2727
DEBUG = 1
2828

29-
app.run(debug=DEBUG)
29+
app.run(debug=DEBUG) # NOT OK
3030

3131
if False:
3232
app.run(debug=True)
3333

3434

3535

3636
runapp = app.run
37-
runapp(debug=True)
37+
runapp(debug=True) # NOT OK
38+
39+
40+
# imports from other module
41+
import settings
42+
app.run(debug=settings.ALWAYS_TRUE) # NOT OK
43+
44+
45+
# depending on environment values
46+
import os
47+
48+
DEPENDS_ON_ENV = os.environ["ENV"] == "dev"
49+
50+
app.run(debug=DEPENDS_ON_ENV) # OK

0 commit comments

Comments
 (0)