mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: override genEnclosingCallable
achieved flow out of functions!
This commit is contained in:
@@ -122,11 +122,19 @@ class ReturnKind extends TReturnKind {
|
||||
|
||||
/** A data flow node that represents a value returned by a callable. */
|
||||
class ReturnNode extends Node {
|
||||
Return ret;
|
||||
|
||||
// See `TaintTrackingImplementation::returnFlowStep`
|
||||
ReturnNode() { this.asCfgNode() = any(Return r).getValue().getAFlowNode() }
|
||||
ReturnNode() {
|
||||
this.asCfgNode() = ret.getValue().getAFlowNode()
|
||||
}
|
||||
|
||||
/** Gets the kind of this return node. */
|
||||
ReturnKind getKind() { result = TNormalReturnKind() }
|
||||
|
||||
override DataFlowCallable getEnclosingCallable() {
|
||||
result.getScope().getAStmt() = ret // TODO: check nested function definitions
|
||||
}
|
||||
}
|
||||
|
||||
/** A data flow node that represents the output of a call. */
|
||||
|
||||
@@ -48,7 +48,7 @@ class Node extends TNode {
|
||||
}
|
||||
|
||||
/** Gets the enclosing callable of this node. */
|
||||
final DataFlowCallable getEnclosingCallable() {
|
||||
DataFlowCallable getEnclosingCallable() {
|
||||
none()
|
||||
}
|
||||
|
||||
@@ -99,13 +99,17 @@ class ParameterNode extends Node {
|
||||
this.asEssaNode() instanceof ParameterDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Holds if this node is the parameter of callable `c` at the specified
|
||||
* (zero-based) position.
|
||||
*/
|
||||
predicate isParameterOf(DataFlowCallable c, int i) {
|
||||
this.asEssaNode().(ParameterDefinition).getDefiningNode() = c.getParameter(i)
|
||||
}
|
||||
|
||||
override DataFlowCallable getEnclosingCallable() {
|
||||
this.isParameterOf(result, _)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| test.py:4:10:4:10 | ControlFlowNode for z | test.py:7:5:7:20 | ControlFlowNode for obfuscated_id() |
|
||||
|
||||
Reference in New Issue
Block a user