mate_common.models.graphs module

class mate_common.models.graphs.FlowfinderEdge(*, edge_id: str, edge_kind: str, source_id: str, target_id: str)

Bases: pydantic.main.BaseModel

Data representing a CPG edge needed by flowfinder.

Parameters
  • edge_id (str) –

  • edge_kind (str) –

  • source_id (str) –

  • target_id (str) –

Return type

None

edge_id: str

The ID of the edge in the CPG.

edge_kind: str

The edge’s edge_kind.

source_id: str

The edge’s source_id.

target_id: str

The edge’s target_id.

class mate_common.models.graphs.FlowfinderGraph(*, nodes: List[mate_common.models.graphs.FlowfinderNode], edges: List[mate_common.models.graphs.FlowfinderEdge])

Bases: pydantic.main.BaseModel

A nodelist and edgelist graph representation, with info needed by flowfinder.

Parameters
Return type

None

edges: List[mate_common.models.graphs.FlowfinderEdge]

The edges in this graph.

nodes: List[mate_common.models.graphs.FlowfinderNode]

The nodes in this graph.

class mate_common.models.graphs.FlowfinderNode(*, node_id: str, node_kind: str, opcode: str = None, source_id: str = None, function_id: str = None, label: str)

Bases: pydantic.main.BaseModel

Data representing a CPG node needed by flowfinder.

Parameters
  • node_id (str) –

  • node_kind (str) –

  • opcode (Optional[str]) –

  • source_id (Optional[str]) –

  • function_id (Optional[str]) –

  • label (str) –

Return type

None

function_id: Optional[str]

If the node is an instruction, the demangled name of it’s parent function.

label: str

A human readable string representation of this node.

node_id: str

The ID of the node in the CPG.

node_kind: str

The node’s node_kind.

opcode: Optional[str]

If the node is an instruction, the node’s opcode.

source_id: Optional[str]

If the node is an instruction, the line of source code corresponding to this instruction.

class mate_common.models.graphs.GraphKind(value)

Bases: str, enum.Enum

Valid kinds of graphs to request.

AliasedMemory = 'aliased_memory_locations'
CallSites = 'callsites'
Callees = 'callees'
Callers = 'callers'
ForwardAllocation = 'forward_allocation'
ForwardControlDependence = 'forward_control_dependence'
ForwardControlFlow = 'forward_control_flow'
ForwardDataflow = 'forward_dataflow'
ForwardMemorySubregion = 'forward_memory_subregion'
ForwardPointsTo = 'forward_points_to'
ForwardPointsToReachable = 'forward_points_to_reachable'
Operands = 'operands'
ReverseAllocation = 'reverse_allocation'
ReverseControlDependence = 'reverse_control_dependence'
ReverseControlFlow = 'reverse_control_flow'
ReverseDataflow = 'reverse_dataflow'
ReverseMemorySubregion = 'reverse_memory_subregion'
ReversePointsTo = 'reverse_points_to'
ReversePointsToReachable = 'reverse_points_to_reachable'
Signatures = 'signatures'
Uses = 'uses'
class mate_common.models.graphs.GraphRequest(*, build_id: str, origin_node_ids: List[str], kind: mate_common.models.graphs.GraphKind, request_kind: mate_common.models.graphs.GraphRequestKind = GraphRequestKind.Graph)

Bases: pydantic.main.BaseModel

Parameters to request a graph.

Parameters
Return type

None

build_id: str

The CPG to query within.

kind: mate_common.models.graphs.GraphKind

Choose from available GraphKinds.

origin_node_ids: List[str]

Nodes around which to run the query.

class mate_common.models.graphs.GraphRequestKind(value)

Bases: str, enum.Enum

These should correspond to the /graphs endpoints.

Graph = 'graph'
Node = 'node'
Slice = 'slice'
class mate_common.models.graphs.NodeRequest(*, build_id: str, node_id: str, request_kind: mate_common.models.graphs.GraphRequestKind = GraphRequestKind.Node)

Bases: pydantic.main.BaseModel

Parameters to request a node.

Parameters
Return type

None

build_id: str

The CPG to query within.

node_id: str

The Node to query for.

class mate_common.models.graphs.SliceRequest(*, build_id: str, source_id: str, sink_id: str, kind: mate_common.models.graphs.GraphKind, avoid_node_ids: List[str] = None, focus_node_ids: List[str] = None, request_kind: mate_common.models.graphs.GraphRequestKind = GraphRequestKind.Slice)

Bases: pydantic.main.BaseModel

Parameters to request a slice.

Parameters
Return type

None

avoid_node_ids: Optional[List[str]]

The slice will exclude paths through these nodes.

build_id: str

The CPG to query within.

focus_node_ids: Optional[List[str]]

The slice will include only paths through these nodes.

kind: mate_common.models.graphs.GraphKind

Choose from: dataflow, control_flow, reverse_control_dependence, call_graph.

sink_id: str

ID of the node at which to end the slice.

source_id: str

ID of the node at which to start the slice.