VulnCheck.Entrypoints.Behaviours (VulnCheck v1.0.1)

Copy Markdown View Source

Synthesizes the call edges that OTP and framework behaviours create at runtime and that never appear as direct calls in the bytecode.

  • Starting a behaviour module (start_link/*, child_spec/1, init/1, new/* for Oban workers, __live__/0 for LiveViews) links all of its callbacks (:behaviour_callback).
  • A literal reference to a module (a supervisor child, a plug, a registered GenServer name, a router target) links the referencing function to that module's start functions and callbacks (:supervisor_child).
  • apply(Mod, fun, args) with a known module and an unknown function links every exported function of matching arity as a candidate.
  • Protocol functions are linked to the matching defimpl functions.
  • Plug.Parsers is linked only to the parsers configured statically (parsers: [:json]), or to every parser when the list is dynamic; parsers are linked to the callback modules of their options (body reader, JSON decoder).
  • Framework dispatch through a module held in a variable is linked to the implementations of the framework's behaviour: ThousandIsland transports, Mint connections and transports.
  • The Tesla middleware stack (Tesla.run/2) is linked to the call functions of the modules named in reachable code or configuration.

Summary

Functions

Callback signatures ("name/arity") known for a behaviour.

Functions that a reference to module may run: start functions and behaviour callbacks that the module defines.

Computes all synthetic edges for the loaded modules.

Types

result()

@type result() :: %{
  edges: [VulnCheck.Types.CallEdge.t()],
  resolved_dynamic_modules: %{required(String.t()) => [String.t()]},
  resolved_dynamic_calls: MapSet.t(VulnCheck.Types.DynamicCall.t()),
  active_plug_parsers: [String.t()] | :all,
  state: term()
}

Functions

callbacks(behaviour)

@spec callbacks(String.t()) :: [String.t()]

Callback signatures ("name/arity") known for a behaviour.

entry_functions(summary)

@spec entry_functions(VulnCheck.Types.ModuleSummary.t()) :: [VulnCheck.Types.MFA.t()]

Functions that a reference to module may run: start functions and behaviour callbacks that the module defines.

synthesize(call_graph, opts \\ [])

@spec synthesize(VulnCheck.Beam.CallGraph.t(), keyword()) :: result()

Computes all synthetic edges for the loaded modules.

Options:

  • :reachable (a set of functions, default :all) restricts the Plug.Parsers configurations and the module names that feed dynamic framework calls to those written in these functions;
  • :configured_modules — modules named by the project configuration.