Skip to content

Commit 35876f1

Browse files
committed
Python: Re-introduce Response::instance() in flask model
We don't actually need it for anything right now, but I have plans for the future where would need it. Although it would be nice to have it as an `API::Node`, and we could re-write implementations so we could provide it in this instance, I'm not convinced we can do that in general right now. For example, if <n'th> parameter of a function has to be modeled as belonging to a certain type, I don't see any way to specify that as an API::Node. For me, that's ok. Until we _can_ specify things like this as API::Nodes in the future, I would like to keep things consistent, and use `DataFlow::Node` as the result type.
1 parent 141e266 commit 35876f1

File tree

1 file changed

+11
-3
lines changed
  • python/ql/src/semmle/python/frameworks

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,17 @@ private module FlaskModel {
155155

156156
override DataFlow::Node getMimetypeOrContentTypeArg() { none() }
157157
}
158-
// TODO: Enable again, but take `InstanceSource` into account
159-
// /** Gets a reference to an instance of `flask.Response`. */
160-
// API::Node instance() { result = classRef().getReturn() }
158+
159+
/** Gets a reference to an instance of `flask.Response`. */
160+
private DataFlow::LocalSourceNode instance(DataFlow::TypeTracker t) {
161+
t.start() and
162+
result instanceof InstanceSource
163+
or
164+
exists(DataFlow::TypeTracker t2 | result = instance(t2).track(t2, t))
165+
}
166+
167+
/** Gets a reference to an instance of `flask.Response`. */
168+
DataFlow::Node instance() { instance(DataFlow::TypeTracker::end()).flowsTo(result) }
161169
}
162170

163171
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)