io.shiftleft.passes

Members list

Type members

Classlikes

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.

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

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

Base trait for all CPG passes. Defines the lifecycle methods that every pass must implement: createAndApply for standalone execution, and runWithBuilder for composing passes that share a single DiffGraphBuilder.

Base trait for all CPG passes. Defines the lifecycle methods that every pass must implement: createAndApply for standalone execution, and runWithBuilder for composing passes that share a single DiffGraphBuilder.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
abstract class ForkJoinParallelCpgPass[T <: AnyRef](cpg: Cpg, outname: String = ...) extends ForkJoinParallelCpgPassWithAccumulator[T, Null]

A parallel CPG pass using the fork/join model.

A parallel CPG pass using the fork/join model.

Instead of returning an Iterator, generateParts returns an Array. This means that the entire collection of parts must live on the heap at the same time; on the other hand, there are no possible issues with iterator invalidation, e.g. when running over all METHOD nodes and deleting some of them.

Instead of streaming writes as ParallelCpgPass do, all runOnPart invocations read the initial state of the graph. Then all changes (accumulated in the DiffGraphBuilders) are merged into a single change, and applied in one go.

In other words, the parallelism follows the fork/join parallel map-reduce (java: collect, scala: aggregate) model. The effect is identical as if one were to sequentially run runOnPart on all output elements of generateParts in sequential order, with the same builder.

This simplifies semantics and makes it easy to reason about possible races.

Note that ForkJoinParallelCpgPass never writes intermediate results, so one must consider peak memory consumption when porting from ParallelCpgPass.

Initialization and cleanup of external resources or large datastructures can be done in the init and finish methods. This may be better than using the constructor or GC, because e.g. SCPG chains of passes construct passes eagerly, and releases them only when the entire chain has run.

This is a simplified form of ForkJoinParallelCpgPassWithAccumulator that does not use an accumulator.

Type parameters

T

the type of each part produced by generateParts

Value parameters

cpg

the code property graph to modify

outname

optional output name

Attributes

Supertypes
trait CpgPassBase
class Object
trait Matchable
class Any
Known subtypes
class CpgPass
abstract class ForkJoinParallelCpgPassWithAccumulator[T <: AnyRef, Accumulator <: AnyRef](cpg: Cpg, outName: String = ...) extends CpgPassBase

A parallel CPG pass with an accumulator for aggregating side results.

A parallel CPG pass with an accumulator for aggregating side results.

This is the most general form of the fork/join pass framework. It extends ForkJoinParallelCpgPass with an accumulator of type Accumulator that each parallel worker maintains locally. After all parts are processed, worker accumulators are merged via mergeAccumulator, and the final merged accumulator is passed to onAccumulatorComplete where additional graph changes can be recorded.

Type parameters

Accumulator

the type of the accumulator used during parallel execution

T

the type of each part produced by generateParts

Value parameters

cpg

the code property graph to modify

outName

optional output name

Attributes

Supertypes
trait CpgPassBase
class Object
trait Matchable
class Any
Known subtypes
class ParallelIteratorExecutor[T](iterator: Iterator[T])(implicit executionContext: ExecutionContext)

Attributes

Supertypes
class Object
trait Matchable
class Any

Deprecated classlikes

abstract class SimpleCpgPass(cpg: Cpg, outName: String = ...) extends CpgPass

Attributes

Deprecated

Use CpgPass instead.

Supertypes
class CpgPass
class ForkJoinParallelCpgPass[AnyRef]
trait CpgPassBase
class Object
trait Matchable
class Any
Show all