Package com.tonic.analysis.cpg
Class CPGBuilder
- java.lang.Object
-
- com.tonic.analysis.cpg.CPGBuilder
-
public class CPGBuilder extends Object
Builder that lifts every method in a class pool to SSA IR and assembles aCodePropertyGraphwith optional call-graph, PDG, and SDG edge layers.
-
-
Constructor Summary
Constructors Constructor Description CPGBuilder(ClassPool classPool)Creates a builder over the given class pool.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CodePropertyGraphbuild()Lifts all methods and assembles the graph with the configured edge layers.static CPGBuilderforClassPool(ClassPool pool)Creates a builder over the given class pool.Map<IRBlock,BlockNode>getBlockNodes()CallGraphgetCallGraph()ClassPoolgetClassPool()CodePropertyGraphgetCpg()Map<IRInstruction,InstructionNode>getInstructionNodes()Map<MethodReference,IRMethod>getIrMethods()Map<MethodReference,MethodNode>getMethodNodes()booleanisIncludeCallGraph()booleanisIncludePDG()booleanisIncludeSDG()CPGBuilderwithCallGraph()Builds a call graph from the class pool and enables call edges.CPGBuilderwithCallGraph(CallGraph callGraph)Reuses a prebuilt call graph and enables call edges.CPGBuilderwithoutCallGraph()Disables call-graph edges.CPGBuilderwithoutPDG()Disables PDG edges.CPGBuilderwithPDG()Enables intraprocedural dependence (PDG) edges.CPGBuilderwithSDG()Enables interprocedural (SDG) edges; implies PDG edges.
-
-
-
Constructor Detail
-
CPGBuilder
public CPGBuilder(ClassPool classPool)
Creates a builder over the given class pool.- Parameters:
classPool- the classes whose methods populate the graph
-
-
Method Detail
-
getClassPool
public ClassPool getClassPool()
- Returns:
- the class pool
-
getCpg
public CodePropertyGraph getCpg()
- Returns:
- the cpg
-
getCallGraph
public CallGraph getCallGraph()
- Returns:
- the call graph
-
isIncludeCallGraph
public boolean isIncludeCallGraph()
- Returns:
- whether call-graph edges will be built
-
isIncludePDG
public boolean isIncludePDG()
- Returns:
- whether PDG edges will be built
-
isIncludeSDG
public boolean isIncludeSDG()
- Returns:
- whether SDG edges will be built
-
getIrMethods
public Map<MethodReference,IRMethod> getIrMethods()
- Returns:
- the ir methods
-
getInstructionNodes
public Map<IRInstruction,InstructionNode> getInstructionNodes()
- Returns:
- the instruction nodes
-
getMethodNodes
public Map<MethodReference,MethodNode> getMethodNodes()
- Returns:
- the method nodes
-
forClassPool
public static CPGBuilder forClassPool(ClassPool pool)
Creates a builder over the given class pool.- Parameters:
pool- the classes whose methods populate the graph- Returns:
- a new builder
-
withCallGraph
public CPGBuilder withCallGraph(CallGraph callGraph)
Reuses a prebuilt call graph and enables call edges.- Parameters:
callGraph- the call graph to reuse- Returns:
- this builder
-
withCallGraph
public CPGBuilder withCallGraph()
Builds a call graph from the class pool and enables call edges.- Returns:
- this builder
-
withPDG
public CPGBuilder withPDG()
Enables intraprocedural dependence (PDG) edges.- Returns:
- this builder
-
withSDG
public CPGBuilder withSDG()
Enables interprocedural (SDG) edges; implies PDG edges.- Returns:
- this builder
-
withoutCallGraph
public CPGBuilder withoutCallGraph()
Disables call-graph edges.- Returns:
- this builder
-
withoutPDG
public CPGBuilder withoutPDG()
Disables PDG edges.- Returns:
- this builder
-
build
public CodePropertyGraph build()
Lifts all methods and assembles the graph with the configured edge layers.- Returns:
- the completed code property graph
-
-