Skip to content

Commit 0cb8e12

Browse files
committed
Python: Fix flask request modeling
This takes us part of the way. We still get multiple paths for the same alert, but that will be fixed in a different PR.
1 parent 9b03e1c commit 0cb8e12

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

python/ql/lib/semmle/python/frameworks/Flask.qll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,7 @@ module Flask {
354354
* See https://flask.palletsprojects.com/en/1.1.x/api/#flask.Request
355355
*/
356356
private class FlaskRequestSource extends RemoteFlowSource::Range {
357-
FlaskRequestSource() {
358-
this = request().getAValueReachableFromSource() and
359-
not any(Import imp).contains(this.asExpr()) and
360-
not exists(ControlFlowNode def | this.asVar().getSourceVariable().hasDefiningNode(def) |
361-
any(Import imp).contains(def.getNode())
362-
)
363-
}
357+
FlaskRequestSource() { this = request().asSource() }
364358

365359
override string getSourceType() { result = "flask.request" }
366360
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: fix
3+
---
4+
* Fixed how `flask.request` is modeled as a RemoteFlowSource, such that we show fewer duplicated alert messages for Code Scanning alerts. The import, such as `from flask import request`, will now be shown as the first step in a path explanation.

0 commit comments

Comments
 (0)