io.joern.x2cpg.passes.frontend

Members list

Concise view

Type members

Classlikes

case class CDereference() extends Dereference

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class CallAlias(identifier: String, receiverName: Option[String]) extends LocalKey

A name that refers to some kind of callee.

A name that refers to some kind of callee.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class LocalKey
class SBKey
class Object
trait Matchable
class Any
case class CollectionVar(identifier: String, idx: String) extends LocalKey

A collection object that can be accessed with potentially dynamic keys and values.

A collection object that can be accessed with potentially dynamic keys and values.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class LocalKey
class SBKey
class Object
trait Matchable
class Any
case class DefaultDereference() extends Dereference

Attributes

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

Attributes

Companion:
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait Dereference

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
sealed class LocalKey(identifier: String) extends SBKey

Represents an identifier of some AST node at an intraprocedural scope.

Represents an identifier of some AST node at an intraprocedural scope.

Attributes

Graph
Supertypes
class SBKey
class Object
trait Matchable
class Any
Known subtypes
case class LocalVar(identifier: String) extends LocalKey

A variable that holds data within an intraprocedural scope.

A variable that holds data within an intraprocedural scope.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class LocalKey
class SBKey
class Object
trait Matchable
class Any
class MetaDataPass(cpg: Cpg, language: String, root: String) extends CpgPass

A pass that creates a MetaData node, specifying that this is a CPG for language, and a NamespaceBlock for anything that cannot be assigned to any other namespace.

A pass that creates a MetaData node, specifying that this is a CPG for language, and a NamespaceBlock for anything that cannot be assigned to any other namespace.

Attributes

Companion:
object
Graph
Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class RecoverForXCompilationUnit[CompilationUnitType <: AstNode](cpg: Cpg, cu: CompilationUnitType, builder: DiffGraphBuilder, state: XTypeRecoveryState) extends RecursiveTask[Boolean]

Performs type recovery from the root of a compilation unit level

Performs type recovery from the root of a compilation unit level

Attributes

CompilationUnitType

the AstNode type used to represent a compilation unit of the language.

builder

the graph builder

cpg

the graph.

cu

a compilation unit, e.g. file, procedure, type, etc.

Graph
Supertypes
class RecursiveTask[Boolean]
class ForkJoinTask[Boolean]
trait Serializable
trait Future[Boolean]
class Object
trait Matchable
class Any
abstract class SBKey(val identifier: String)

Represents an identifier of some AST node at a specific scope.

Represents an identifier of some AST node at a specific scope.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object SBKey

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
SBKey.type
class SymbolTable[K <: SBKey](val keyFromNode: AstNode => Option[K])

A thread-safe symbol table that can represent multiple types per symbol. Each node in an AST gets converted to an SBKey which gives contextual information to identify an AST entity. Each value in this table represents a set of types that the key could be in a flow-insensitive manner.

A thread-safe symbol table that can represent multiple types per symbol. Each node in an AST gets converted to an SBKey which gives contextual information to identify an AST entity. Each value in this table represents a set of types that the key could be in a flow-insensitive manner.

The SymbolTable operates like a map with a few convenient methods that are designed for this structure's purpose.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
class TypeNodePass(usedTypes: List[String], cpg: Cpg, keyPool: Option[KeyPool]) extends CpgPass

Creates a TYPE node for each type in usedTypes

Creates a TYPE node for each type in usedTypes

Attributes

Companion:
object
Graph
Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class XInheritanceFullNamePass(cpg: Cpg) extends CpgPass

Using some basic heuristics, will try to resolve type full names from types found within the CPG. Requires ImportPass as a pre-requisite.

Using some basic heuristics, will try to resolve type full names from types found within the CPG. Requires ImportPass as a pre-requisite.

Attributes

Graph
Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any
abstract class XTypeHintCallLinker(cpg: Cpg) extends CpgPass

Attempts to set the methodFullName and link to callees using the recovered type information from XTypeRecovery. Note that some methods may not be present as they could be external and have been dynamically discovered, thus the io.joern.x2cpg.passes.base.MethodStubCreator would have missed it.

Attempts to set the methodFullName and link to callees using the recovered type information from XTypeRecovery. Note that some methods may not be present as they could be external and have been dynamically discovered, thus the io.joern.x2cpg.passes.base.MethodStubCreator would have missed it.

Attributes

cpg

the target code property graph.

Companion:
object
Graph
Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class XTypeRecovery[CompilationUnitType <: AstNode](cpg: Cpg, state: XTypeRecoveryState) extends CpgPass

Based on a flow-insensitive static single-assignment symbol-table-style approach. This pass aims to be fast and deterministic and does not try to converge to some fixed point but rather iterates a fixed number of times. This will help recover:

Based on a flow-insensitive static single-assignment symbol-table-style approach. This pass aims to be fast and deterministic and does not try to converge to some fixed point but rather iterates a fixed number of times. This will help recover:

  • Imported call signatures from external dependencies
  • Dynamic type hints for mutable variables in a compilation unit.

The algorithm flows roughly as follows:

  • Scan for method signatures of methods for each compilation unit, either by internally defined methods or by reading import signatures. This includes looking for aliases, e.g. import foo as bar.
  • (Optionally) Prune these method signatures by checking their validity against the CPG.
  • Visit assignments to populate where variables are assigned a value to extrapolate its type. Store these values in a local symbol table. If a field is assigned a value, store this in the global table
  • Find instances of where these fields and variables are used and update their type information.
  • If this variable is the receiver of a call, make sure to set the type of the call accordingly.

The symbol tables use the SymbolTable class to track possible type information.
Note: Local symbols are cleared once a compilation unit is complete. This is to keep memory usage down while maximizing concurrency.

Attributes

CompilationUnitType

the AstNode type used to represent a compilation unit of the language.

cpg

the CPG to recovery types for.

Companion:
object
Graph
Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
case class XTypeRecoveryConfig(iterations: Int, enabledDummyTypes: Boolean)

Attributes

enabledDummyTypes

whether to enable placeholder dummy values for partially resolved types.

iterations

the number of iterations to run.

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
abstract class XTypeRecoveryPass[CompilationUnitType <: AstNode](cpg: Cpg, config: XTypeRecoveryConfig) extends CpgPass

In order to propagate types across compilation units, but avoid the poor scalability of a fixed-point algorithm, the number of iterations can be configured using the iterations parameter. Note that iterations < 2 will not provide any interprocedural type recovery capabilities.

In order to propagate types across compilation units, but avoid the poor scalability of a fixed-point algorithm, the number of iterations can be configured using the iterations parameter. Note that iterations < 2 will not provide any interprocedural type recovery capabilities.

Attributes

CompilationUnitType

the AstNode type used to represent a compilation unit of the language.

cpg

the CPG to recovery types for.

Graph
Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
class NewStyleCpgPassBase[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any
case class XTypeRecoveryState(config: XTypeRecoveryConfig, currentIteration: Int, isFieldCache: TrieMap[Long, Boolean], changesWereMade: AtomicBoolean, stopEarly: AtomicBoolean)

Attributes

changesWereMade

a flag to indicate that changes were made in the last iteration.

config

the user defined config.

currentIteration

the current iteration.

isFieldCache

a cache for answering if a node represents a field or member.

stopEarly

indicates that we may stop type propagation earlier than the specified number of iterations.

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