Packages

abstract class XTypeRecovery[CompilationUnitType <: AstNode] extends CpgPass

Based on a flow-insensitive 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.

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.

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.

CompilationUnitType

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

Linear Supertypes
CpgPass, ForkJoinParallelCpgPass[AnyRef], NewStyleCpgPassBase[AnyRef], CpgPassBase, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. XTypeRecovery
  2. CpgPass
  3. ForkJoinParallelCpgPass
  4. NewStyleCpgPassBase
  5. CpgPassBase
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new XTypeRecovery(cpg: Cpg, iterations: Int = 2)

    cpg

    the CPG to recovery types for.

    iterations

    the total number of iterations through which types are to be propagated. At least 2 are recommended in order to propagate interprocedural types. Think of this as similar to the dataflowengineoss' 'maxCallDepth'.

Type Members

  1. type DiffGraphBuilder = overflowdb.BatchedUpdate.DiffGraphBuilder
    Definition Classes
    NewStyleCpgPassBase

Abstract Value Members

  1. abstract def compilationUnit: Traversal[CompilationUnitType]

    returns

    the compilation units as per how the language is compiled. e.g. file.

  2. abstract def generateRecoveryForCompilationUnitTask(unit: CompilationUnitType, builder: DiffGraphBuilder): RecoverForXCompilationUnit[CompilationUnitType]

    A factory method to generate a RecoverForXCompilationUnit task with the given parameters.

    A factory method to generate a RecoverForXCompilationUnit task with the given parameters.

    unit

    the compilation unit.

    builder

    the graph builder.

    returns

    a forkable RecoverForXCompilationUnit task.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val addedNodes: HashSet[(Long, String)]

    In the case of new nodes being added, will make sure these aren't duplicated because of future iterations.

    In the case of new nodes being added, will make sure these aren't duplicated because of future iterations. This comes in pairs of parent ID -> string identifier.

    Attributes
    protected
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def baseLogger: Logger
    Attributes
    protected
    Definition Classes
    CpgPassBase
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. def createAndApply(): Unit
    Definition Classes
    NewStyleCpgPassBase → CpgPassBase
  9. def createApplySerializeAndStore(serializedCpg: SerializedCpg, inverse: Boolean, prefix: String): Unit
    Definition Classes
    ForkJoinParallelCpgPass → CpgPassBase
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. def finish(): Unit
    Definition Classes
    NewStyleCpgPassBase
  13. def generateOutFileName(prefix: String, outName: String, index: Int): String
    Attributes
    protected
    Definition Classes
    CpgPassBase
  14. final def generateParts(): Array[_ <: AnyRef]
    Definition Classes
    CpgPass → NewStyleCpgPassBase
  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. val globalTable: SymbolTable[GlobalKey]

    Stores type information for global structures that persist across compilation units, e.g.

    Stores type information for global structures that persist across compilation units, e.g. field identifiers.

    Attributes
    protected
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def init(): Unit
    Definition Classes
    NewStyleCpgPassBase
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def name: String
    Definition Classes
    CpgPassBase
  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def run(builder: DiffGraphBuilder): Unit
    Definition Classes
    XTypeRecovery → CpgPass
  25. final def runOnPart(builder: overflowdb.BatchedUpdate.DiffGraphBuilder, part: AnyRef): Unit
    Definition Classes
    CpgPass → NewStyleCpgPassBase
  26. def runWithBuilder(externalBuilder: overflowdb.BatchedUpdate.DiffGraphBuilder): Int
    Definition Classes
    NewStyleCpgPassBase → CpgPassBase
  27. def runWithBuilderLogged(builder: overflowdb.BatchedUpdate.DiffGraphBuilder): Int
    Definition Classes
    CpgPassBase
  28. def store(overlay: GeneratedMessageV3, name: String, serializedCpg: SerializedCpg): Unit
    Attributes
    protected
    Definition Classes
    CpgPassBase
  29. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  34. def withStartEndTimesLogged[A](fun: => A): A
    Attributes
    protected
    Definition Classes
    CpgPassBase

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from CpgPass

Inherited from ForkJoinParallelCpgPass[AnyRef]

Inherited from NewStyleCpgPassBase[AnyRef]

Inherited from CpgPassBase

Inherited from AnyRef

Inherited from Any

Ungrouped