From 367a49803bc6633ea3fbedfe9ccb20ddc2f44301 Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Fri, 24 Jul 2020 11:19:11 +0200 Subject: [PATCH] Python: CG trace: handle class instantiation properly in points-to --- .../recorded-call-graph-metrics/ql/RecordedCalls.qll | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll b/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll index bf666d58a0f..f55952dd2b0 100644 --- a/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll +++ b/python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll @@ -248,7 +248,14 @@ module PointsToBasedCallGraph { xmlCallee = this.getXMLCallee() and ( xmlCallee instanceof XMLPythonCallee and - calleeValue.(PythonFunctionValue).getScope() = xmlCallee.(XMLPythonCallee).getACallee() + ( + // normal function + calleeValue.(PythonFunctionValue).getScope() = xmlCallee.(XMLPythonCallee).getACallee() + or + // class instantiation -- points-to says the call goes to the class + calleeValue.(ClassValue).lookup("__init__").(PythonFunctionValue).getScope() = + xmlCallee.(XMLPythonCallee).getACallee() + ) or xmlCallee instanceof XMLExternalCallee and calleeValue.(BuiltinFunctionObjectInternal).getBuiltin() =