PythonModuleDefinedCallLinker

class PythonModuleDefinedCallLinker(cpg: Cpg) extends SimpleCpgPass

Attempts to set the methodFullName and dispatchType properties of calls where the callees are defined under a module.

Value parameters:
cpg

the target code property graph.

class SimpleCpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any

Type members

Classlikes

case class ProcInScope(callingName: String, fullNameAsPyFile: String)

Defines how a procedure is available to be called in the current scope.

Defines how a procedure is available to be called in the current scope.

Value parameters:
callingName

how this procedure is to be called, i.e., alias name, name with path, etc.

fullNameAsPyFile

the full name to where this method is defined where it's assumed to be defined under a named Python file.

Inherited types

type DiffGraphBuilder = DiffGraphBuilder
Inherited from:
NewStyleCpgPassBase

Value members

Concrete methods

def extractLocallyDefinedMethods(module: Method): Map[String, ProcInScope]

Returns all method declarations within this module that are not defined under a class definition.

Returns all method declarations within this module that are not defined under a class definition.

TODO: Some classes may annotate their methods as static

Value parameters:
module

the module to search within.

Returns:

a mapping of the method names and their procedures.

Parses all imports and identifies their full names and how they are to be called in this scope.

Parses all imports and identifies their full names and how they are to be called in this scope.

Value parameters:
i

the import call.

Returns:

the procedure information in this scope.

def linkCalleeIfPresent(call: Call, procInScope: ProcInScope, builder: DiffGraphBuilder): Unit

If we can find the method that this name belongs to, then link the call edge.

If we can find the method that this name belongs to, then link the call edge.

Value parameters:
builder

the diff graph builder.

call

the source call node.

procInScope

scope information about the callee.

override def run(builder: DiffGraphBuilder): Unit
Definition Classes
SimpleCpgPass
def runOnModule(module: Method, builder: DiffGraphBuilder): Unit

Inherited methods

override def createAndApply(): Unit
Definition Classes
NewStyleCpgPassBase -> CpgPassBase
Inherited from:
NewStyleCpgPassBase
override def createApplySerializeAndStore(serializedCpg: SerializedCpg, inverse: Boolean, prefix: String): Unit
Definition Classes
ForkJoinParallelCpgPass -> CpgPassBase
Inherited from:
ForkJoinParallelCpgPass
def finish(): Unit
Inherited from:
NewStyleCpgPassBase
final override def generateParts(): Array[_ <: AnyRef]
Definition Classes
SimpleCpgPass -> NewStyleCpgPassBase
Inherited from:
SimpleCpgPass
def init(): Unit
Inherited from:
NewStyleCpgPassBase
def name: String

Name of the pass. By default it is inferred from the name of the class, override if needed.

Name of the pass. By default it is inferred from the name of the class, override if needed.

Inherited from:
CpgPassBase
final override def runOnPart(builder: DiffGraphBuilder, part: AnyRef): Unit
Definition Classes
SimpleCpgPass -> NewStyleCpgPassBase
Inherited from:
SimpleCpgPass
override def runWithBuilder(externalBuilder: DiffGraphBuilder): Int
Definition Classes
NewStyleCpgPassBase -> CpgPassBase
Inherited from:
NewStyleCpgPassBase
def runWithBuilderLogged(builder: DiffGraphBuilder): Int

Wraps runWithBuilder with logging, and swallows raised exceptions. Use with caution -- API is unstable. A return value of -1 indicates failure, otherwise the return value of runWithBuilder is passed through.

Wraps runWithBuilder with logging, and swallows raised exceptions. Use with caution -- API is unstable. A return value of -1 indicates failure, otherwise the return value of runWithBuilder is passed through.

Inherited from:
CpgPassBase