ProtoToGraphNodeMappings

io.shiftleft.codepropertygraph.cpgloading.ProtoToGraphNodeMappings

Mutable datastructure to preserve mapping between proto and cpg nodes during ProtoToCpg import.

Context: we need to run two passes: 1) add nodes and 2) set node properties and add edges (this is due to flatgraph-specific implementation details)

Because of that, we need to remember the mapping from proto node id to gnode. Typically that's just a plain mapping, but there's one special case for TYPE nodes: some (parallel) frontends create duplicate TYPE nodes which we need to deduplicate...

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def add(protoNode: Node, node: DNode): Unit
def addAll(other: ProtoToGraphNodeMappings): Unit
def contains(protoNode: Node): Boolean
def find(protoNode: Node): Option[DNode]
def findGNode(protoNode: Node): Option[GNode]

This will fail hard if the DiffGraph hasn't been applied yet, which is the assumption for it's use case. In other words, we specifically don't want to invoke find(protoNode).flatMap(_.storedRef) here

This will fail hard if the DiffGraph hasn't been applied yet, which is the assumption for it's use case. In other words, we specifically don't want to invoke find(protoNode).flatMap(_.storedRef) here

Attributes

def findGNode(protoNodeId: Long): Option[GNode]

This will fail hard if the DiffGraph hasn't been applied yet, which is the assumption for it's use case. In other words, we specifically don't want to invoke find(protoNode).flatMap(_.storedRef) here

This will fail hard if the DiffGraph hasn't been applied yet, which is the assumption for it's use case. In other words, we specifically don't want to invoke find(protoNode).flatMap(_.storedRef) here

Note that this doesn't (and cannot) check for duplicate nodes with the same TYPE.FULL_NAME, because we only have the protoNodeId and not the node itself.

Attributes