Immutable call graph indexed by caller and callee.
Built from module summaries: static and resolved dynamic edges, {M, F, A}
references and, for modules without debug info, over-approximated edges
from every exported function to every imported function (:imports).
Further edges (behaviour callbacks, supervisor children, ...) are added
with add_edges/2.
Summary
Functions
Adds edges to the graph. Duplicate pairs prefer proven edges, with ties keeping the first edge.
Builds the graph from summaries (a map keyed by module name or a list).
Incoming edges of a function.
Number of distinct edges.
Outgoing edges of a function.
Returns true when the module was loaded from a .beam file.
All functions reachable from roots (MFAs or entrypoints), roots included.
Modules containing at least one reachable function.
Finds a shortest call chain (fewest hops) from any root to any target.
Types
@type t() :: %VulnCheck.Beam.CallGraph{ in_edges: %{ required(VulnCheck.Types.MFA.t()) => [VulnCheck.Types.CallEdge.t()] }, modules: %{required(String.t()) => VulnCheck.Types.ModuleSummary.t()}, out_edges: %{ required(VulnCheck.Types.MFA.t()) => [VulnCheck.Types.CallEdge.t()] }, pairs: %{ required({VulnCheck.Types.MFA.t(), VulnCheck.Types.MFA.t()}) => boolean() } }
Functions
@spec add_edges(t(), [VulnCheck.Types.CallEdge.t()]) :: t()
Adds edges to the graph. Duplicate pairs prefer proven edges, with ties keeping the first edge.
@spec build( %{required(String.t()) => VulnCheck.Types.ModuleSummary.t()} | [VulnCheck.Types.ModuleSummary.t()], keyword() ) :: t()
Builds the graph from summaries (a map keyed by module name or a list).
@spec callers(t(), VulnCheck.Types.MFA.t()) :: [VulnCheck.Types.CallEdge.t()]
Incoming edges of a function.
@spec edge_count(t()) :: non_neg_integer()
Number of distinct edges.
@spec edges_from(t(), VulnCheck.Types.MFA.t()) :: [VulnCheck.Types.CallEdge.t()]
Outgoing edges of a function.
Returns true when the module was loaded from a .beam file.
@spec reachable(t(), [VulnCheck.Types.MFA.t() | VulnCheck.Types.Entrypoint.t()]) :: MapSet.t(VulnCheck.Types.MFA.t())
All functions reachable from roots (MFAs or entrypoints), roots included.
@spec reachable_modules(MapSet.t(VulnCheck.Types.MFA.t())) :: MapSet.t(String.t())
Modules containing at least one reachable function.
@spec shortest_path( t(), [VulnCheck.Types.MFA.t() | VulnCheck.Types.Entrypoint.t()], MapSet.t(VulnCheck.Types.MFA.t()) | [VulnCheck.Types.MFA.t()] ) :: {:ok, [VulnCheck.Types.TraceHop.t()]} | :none
Finds a shortest call chain (fewest hops) from any root to any target.
Returns {:ok, hops} where the first hop is the entrypoint and every
following hop carries the call site (file:line) in its caller and the
kind of the edge, or :none.