Python: small start on global flow

need to actually have `OutNode`s
This commit is contained in:
Rasmus Lerchedahl Petersen
2020-06-16 15:36:03 +02:00
parent f3e879a5ab
commit 0f77403f0e

View File

@@ -9,7 +9,7 @@ private import DataFlowPublic
// Nodes
//--------
class DataFlowCall extends Call {
class DataFlowCall extends CallNode {
/** Gets the enclosing callable of this call. */
abstract DataFlowCallable getEnclosingCallable();
}
@@ -103,10 +103,16 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
// Global flow
//--------
class DataFlowCallable = FunctionValue;
import semmle.python.pointsto.CallGraph
class DataFlowCallable = FunctionObject;
/** Gets a viable run-time target for the call `call`. */
DataFlowCallable viableCallable(DataFlowCall call) { none() }
DataFlowCallable viableCallable(DataFlowCall call) {
exists(FunctionInvocation i |
call = i.getCall() and
result = i.getFunction())
}
/**
* Gets a node that can read the value returned from `call` with return kind
@@ -114,6 +120,9 @@ DataFlowCallable viableCallable(DataFlowCall call) { none() }
*/
OutNode getAnOutNode(DataFlowCall call, ReturnKind kind) { call = result.getCall(kind) }
// Extend OutNode here
// Consider whether to use AST nodes rather than CFG nodes
//--------
// Type pruning
//--------