| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + lgtm,codescanning | ||
| 2 | + * Updated _Flask app is run in debug mode_ (`py/flask-debug`) query to use the new type-tracking approach instead of points-to analysis. You may see differences in the results found by the query, but overall this change should result in a more robust and accurate analysis. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,12 +11,25 @@ | |||
| 11 | 11 | */ | |
| 12 | 12 | ||
| 13 | 13 | import python | |
| 14 | - import semmle.python.web.flask.General | ||
| 14 | + import semmle.python.dataflow.new.DataFlow | ||
| 15 | + import semmle.python.ApiGraphs | ||
| 16 | + import semmle.python.frameworks.Flask | ||
| 15 | 17 | ||
| 16 | - from CallNode call, Value isTrue | ||
| 18 | + /** Gets a reference to a truthy literal. */ | ||
| 19 | + private DataFlow::LocalSourceNode truthyLiteral(DataFlow::TypeTracker t) { | ||
| 20 | + t.start() and | ||
| 21 | + result.asExpr().(ImmutableLiteral).booleanValue() = true | ||
| 22 | + or | ||
| 23 | + exists(DataFlow::TypeTracker t2 | result = truthyLiteral(t2).track(t2, t)) | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** Gets a reference to a truthy literal. */ | ||
| 27 | + DataFlow::Node truthyLiteral() { truthyLiteral(DataFlow::TypeTracker::end()).flowsTo(result) } | ||
| 28 | + | ||
| 29 | + from DataFlow::CallCfgNode call, DataFlow::Node debugArg | ||
| 17 | 30 | where | |
| 18 | - call = theFlaskClass().declaredAttribute("run").(FunctionValue).getACall() and | ||
| 19 | - call.getArgByName("debug").pointsTo(isTrue) and | ||
| 20 | - isTrue.getDefiniteBooleanValue() = true | ||
| 31 | + call.getFunction() = Flask::FlaskApp::instance().getMember("run").getAUse() and | ||
| 32 | + debugArg in [call.getArg(2), call.getArgByName("debug")] and | ||
| 33 | + debugArg = truthyLiteral() | ||
| 21 | 34 | select call, | |
| 22 | 35 | "A Flask app appears to be run in debug mode. This may allow an attacker to run arbitrary code through the debugger." | |
| Back | FazBrowse Home | New Git URL |
0 commit comments