Skip to content

Commit 6dea278

Browse files
committed
Python: More refinements
As it turns out, referring to the request object using `flask.request` is not uncommon, and this meant restricting to `Name` nodes was too strong. With the changes in this commit, we now include those occurrences as well.
1 parent f3a5d0a commit 6dea278

File tree

1 file changed

+5
-3
lines changed
  • python/ql/lib/semmle/python/frameworks

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,13 @@ module Flask {
440440
// Using `request().asSource()` would result in data-flow paths starting at the import of
441441
// `request`, which is not very useful. Instead, we look at all the places this `request`
442442
// object can flow, and use only those that are local sources (so we only get the first
443-
// instance of `request` in a function), and those that correspond to `Name` nodes (so we
444-
// don't get the initial import, which is an `ImportMember`).
443+
// instance of `request` in a function), expressions (so we don't get any SSA entry
444+
// definitions), and which don't correspond to an `ImportMember` (so we don't get the
445+
// `from flask import request` occurrence).
445446
this = request().getAValueReachableFromSource() and
446447
this instanceof DataFlow::LocalSourceNode and
447-
this.asExpr() instanceof Name
448+
this instanceof DataFlow::ExprNode and
449+
not this.asExpr() instanceof ImportMember
448450
}
449451

450452
override string getSourceType() { result = "flask.request" }

0 commit comments

Comments
 (0)