PythonModuleDefinedCallLinker

io.joern.x2cpg.passes.frontend.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.

Attributes

cpg

the target code property graph.

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

Members list

Concise view

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.

Attributes

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.

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Inherited types

type DiffGraphBuilder = DiffGraphBuilder

Attributes

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

Attributes

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.

Attributes

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.

Attributes

builder

the diff graph builder.

call

the source call node.

procInScope

scope information about the callee.

override def run(builder: DiffGraphBuilder): Unit

Attributes

Definition Classes
CpgPass
def runOnModule(module: Method, builder: DiffGraphBuilder): Unit

Inherited methods

override def createAndApply(): Unit

Attributes

Definition Classes
NewStyleCpgPassBase -> CpgPassBase
Inherited from:
NewStyleCpgPassBase
override def createApplySerializeAndStore(serializedCpg: SerializedCpg, inverse: Boolean, prefix: String): Unit

Attributes

Definition Classes
ForkJoinParallelCpgPass -> CpgPassBase
Inherited from:
ForkJoinParallelCpgPass
def finish(): Unit

Attributes

Inherited from:
NewStyleCpgPassBase
final override def generateParts(): Array[_ <: AnyRef]

Attributes

Definition Classes
CpgPass -> NewStyleCpgPassBase
Inherited from:
CpgPass
def init(): Unit

Attributes

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.

Attributes

Inherited from:
CpgPassBase
final override def runOnPart(builder: DiffGraphBuilder, part: AnyRef): Unit

Attributes

Definition Classes
CpgPass -> NewStyleCpgPassBase
Inherited from:
CpgPass
override def runWithBuilder(externalBuilder: DiffGraphBuilder): Int

Runs the cpg pass, adding changes to the passed builder. Use with caution -- API is unstable. Returns max(nParts, 1), where nParts is either the number of parallel parts, or the number of iterarator elements in case of legacy passes. Includes init() and finish() logic.

Runs the cpg pass, adding changes to the passed builder. Use with caution -- API is unstable. Returns max(nParts, 1), where nParts is either the number of parallel parts, or the number of iterarator elements in case of legacy passes. Includes init() and finish() logic.

Attributes

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.

Attributes

Inherited from:
CpgPassBase