Skip to content

Commit 2541af6

Browse files
committed
Python: Rewrite py/flask-debug
1 parent 05bca02 commit 2541af6

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

python/ql/src/Security/CWE-215/FlaskDebug.ql

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,10 @@ import semmle.python.dataflow.new.DataFlow
1616
import semmle.python.ApiGraphs
1717
import semmle.python.frameworks.Flask
1818

19-
/** Gets a reference to a truthy literal. */
20-
private DataFlow::TypeTrackingNode truthyLiteral(DataFlow::TypeTracker t) {
21-
t.start() and
22-
result.asExpr().(ImmutableLiteral).booleanValue() = true
23-
or
24-
exists(DataFlow::TypeTracker t2 | result = truthyLiteral(t2).track(t2, t))
25-
}
26-
27-
/** Gets a reference to a truthy literal. */
28-
DataFlow::Node truthyLiteral() { truthyLiteral(DataFlow::TypeTracker::end()).flowsTo(result) }
29-
30-
from API::CallNode call, DataFlow::Node debugArg
19+
from API::CallNode call
3120
where
3221
call = Flask::FlaskApp::instance().getMember("run").getACall() and
33-
debugArg in [call.getArg(2), call.getArgByName("debug")] and
34-
debugArg = truthyLiteral()
22+
call.getParameter(2, "debug").getAValueReachingSink().asExpr().(ImmutableLiteral).booleanValue() =
23+
true
3524
select call,
3625
"A Flask app appears to be run in debug mode. This may allow an attacker to run arbitrary code through the debugger."

0 commit comments

Comments
 (0)