Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48f873e

Browse files
committed
Python: Add getAReturnedNode to PythonFunctionValue
1 parent 582ef6c commit 48f873e

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

python/ql/src/semmle/python/objects/ObjectAPI.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ module Value {
211211
}
212212

213213
/** Gets the `Value` for the integer constant `i`, if it exists.
214-
* There will be no `Value` for most integers, but the following are
214+
* There will be no `Value` for most integers, but the following are
215215
* guaranteed to exist:
216216
* * From zero to 511 inclusive.
217217
* * All powers of 2 (up to 2**30)
@@ -486,6 +486,11 @@ class PythonFunctionValue extends FunctionValue {
486486
)
487487
}
488488

489+
/** Gets a control flow node corresponding to a return statement in this function */
490+
ControlFlowNode getAReturnedNode() {
491+
result = this.getScope().getAReturnValueFlowNode()
492+
}
493+
489494
}
490495

491496
/** Class representing builtin functions, such as `len` or `print` */

python/ql/src/semmle/python/web/flask/Response.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import semmle.python.web.flask.General
99
*/
1010
class FlaskRoutedResponse extends HttpResponseTaintSink {
1111
FlaskRoutedResponse() {
12-
exists(PyFunctionObject response |
13-
flask_routing(_, response.getFunction()) and
12+
exists(PythonFunctionValue response |
13+
flask_routing(_, response.getScope()) and
1414
this = response.getAReturnedNode()
1515
)
1616
}

python/ql/src/semmle/python/web/pyramid/Response.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ private import semmle.python.web.Http
1111
*/
1212
class PyramidRoutedResponse extends HttpResponseTaintSink {
1313
PyramidRoutedResponse() {
14-
exists(PyFunctionObject view |
15-
is_pyramid_view_function(view.getFunction()) and
14+
exists(PythonFunctionValue view |
15+
is_pyramid_view_function(view.getScope()) and
1616
this = view.getAReturnedNode()
1717
)
1818
}

python/ql/src/semmle/python/web/twisted/Response.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class TwistedResponse extends TaintSink {
1111
isKnownRequestHandlerMethodName(name) and
1212
name = func.getName() and
1313
func = getTwistedRequestHandlerMethod(name) and
14-
func.getScope() = ret.getScope() and
15-
ret.getValue().getAFlowNode() = this
14+
this = func.getAReturnedNode()
1615
)
1716
}
1817

0 commit comments

Comments
 (0)