CpgPass

io.shiftleft.passes.CpgPass
abstract class CpgPass(cpg: Cpg, outName: String = ...) extends ForkJoinParallelCpgPass[AnyRef]

A single-threaded CPG pass. This is the simplest pass to implement: override run and add desired graph modifications to the provided DiffGraphBuilder.

Internally implemented as a ForkJoinParallelCpgPass with a single part and parallelism disabled.

Value parameters

cpg

the code property graph to modify

outName

optional name for output

Attributes

Graph
Supertypes
class ForkJoinParallelCpgPass[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Type members

Inherited types

type DiffGraphBuilder = DiffGraphBuilder

Attributes

Inherited from:
ForkJoinParallelCpgPassWithAccumulator

Value members

Abstract methods

def run(builder: DiffGraphBuilder): Unit

The main method to implement. Add all desired graph changes (nodes, edges, properties) to the provided builder.

The main method to implement. Add all desired graph changes (nodes, edges, properties) to the provided builder.

Value parameters

builder

the DiffGraphBuilder that accumulates graph modifications

Attributes

Concrete methods

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

Generate an array of parts to be processed in parallel by runOnPart.

Generate an array of parts to be processed in parallel by runOnPart.

Attributes

Definition Classes
override def isParallel: Boolean

Override and return false to disable parallel execution. Useful for debugging.

Override and return false to disable parallel execution. Useful for debugging.

Attributes

Definition Classes
final override def runOnPart(builder: DiffGraphBuilder, part: AnyRef): Unit

Process a single part and record graph modifications in the provided builder.

Process a single part and record graph modifications in the provided builder.

Value parameters

builder

the DiffGraphBuilder that accumulates graph modifications

part

the part to process, as produced by generateParts

Attributes

Definition Classes

Inherited methods

protected def baseLogger: Logger

Attributes

Inherited from:
CpgPassBase
override def createAccumulator(): Null

Create a fresh accumulator instance. Called once per parallel worker thread.

Create a fresh accumulator instance. Called once per parallel worker thread.

Attributes

Definition Classes
Inherited from:
ForkJoinParallelCpgPass
override def createAndApply(): Unit

Creates a new DiffGraphBuilder, runs the pass (init, generateParts, runOnPart, finish), applies all accumulated changes to the graph, and logs timing information. Exceptions during execution are logged and re-thrown.

Creates a new DiffGraphBuilder, runs the pass (init, generateParts, runOnPart, finish), applies all accumulated changes to the graph, and logs timing information. Exceptions during execution are logged and re-thrown.

Attributes

Definition Classes
Inherited from:
ForkJoinParallelCpgPassWithAccumulator
def finish(): Unit

Called once after all parts have been processed (in a finally block). Use to release resources acquired in init.

Called once after all parts have been processed (in a finally block). Use to release resources acquired in init.

Attributes

Inherited from:
ForkJoinParallelCpgPassWithAccumulator
protected def generateOutFileName(prefix: String, outName: String, index: Int): String

Attributes

Inherited from:
CpgPassBase
def init(): Unit

Called once before generateParts. Use to set up large data structures or acquire external resources.

Called once before generateParts. Use to set up large data structures or acquire external resources.

Attributes

Inherited from:
ForkJoinParallelCpgPassWithAccumulator
override def mergeAccumulator(left: Null, accumulator: Null): Unit

Merge the accumulator (right) into left. Called during the combine phase of fork/join.

Merge the accumulator (right) into left. Called during the combine phase of fork/join.

Attributes

Definition Classes
Inherited from:
ForkJoinParallelCpgPass
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
override def onAccumulatorComplete(builder: DiffGraphBuilder, accumulator: Null): Unit

Called once after all parts are processed and accumulators are merged. Use to record additional graph changes based on the fully merged accumulator.

Called once after all parts are processed and accumulators are merged. Use to record additional graph changes based on the fully merged accumulator.

Value parameters

accumulator

the final merged accumulator

builder

the DiffGraphBuilder for any additional modifications

Attributes

Definition Classes
Inherited from:
ForkJoinParallelCpgPass
override def runOnPart(builder: DiffGraphBuilder, part: AnyRef, acc: Null): Unit

Process a single part, recording graph changes in builder and side results in accumulator.

Process a single part, recording graph changes in builder and side results in accumulator.

Value parameters

accumulator

the thread-local accumulator for this worker

builder

the DiffGraphBuilder that accumulates graph modifications

part

the part to process

Attributes

Definition Classes
Inherited from:
ForkJoinParallelCpgPass
override def runWithBuilder(externalBuilder: DiffGraphBuilder): Int

Runs the full pass lifecycle (init, generateParts, parallel runOnPart, accumulator merge, finish) and absorbs all changes into externalBuilder without applying them to the graph. The caller is responsible for applying the builder.

Runs the full pass lifecycle (init, generateParts, parallel runOnPart, accumulator merge, finish) and absorbs all changes into externalBuilder without applying them to the graph. The caller is responsible for applying the builder.

Value parameters

externalBuilder

the builder to absorb all generated changes into

Attributes

Returns

the number of parts that were processed

Definition Classes
Inherited from:
ForkJoinParallelCpgPassWithAccumulator
def runWithBuilderLogged(builder: DiffGraphBuilder): Int

Wraps runWithBuilder with logging and exception handling. Use with caution — API is unstable.

Wraps runWithBuilder with logging and exception handling. Use with caution — API is unstable.

Value parameters

builder

the DiffGraphBuilder to absorb changes into

Attributes

Returns

the number of parts processed, or -1 if the pass threw an exception

Inherited from:
CpgPassBase
protected def withStartEndTimesLogged[A](fun: => A): A

Executes fun while logging the pass start and completion time (including duration via MDC).

Executes fun while logging the pass start and completion time (including duration via MDC).

Type parameters

A

the return type of the wrapped computation

Value parameters

fun

the computation to execute

Attributes

Returns

the result of fun

Inherited from:
CpgPassBase

Deprecated and Inherited methods

override def createApplySerializeAndStore(serializedCpg: SerializedCpg, prefix: String = ...): Unit

Attributes

Deprecated
Please use createAndApply
Definition Classes
Inherited from:
ForkJoinParallelCpgPassWithAccumulator
protected def store(overlay: GeneratedMessageV3, name: String, serializedCpg: SerializedCpg): Unit

Attributes

Deprecated
true
Inherited from:
CpgPassBase