Walks the Erlang Abstract Format (:raw_abstract_v1) of one module and
produces a VulnCheck.Types.ModuleSummary.
Extracted facts:
- local and remote calls with exact
file:line(:static_call), - function captures (
&Mod.fun/2,fun mod:f/1), apply/3andmod.fun(...)sites; literal modules and functions, including variables bound to a literal in the same clause, are resolved to:dynamic_applyedges, everything else is recorded as aVulnCheck.Types.DynamicCall,{Mod, :fun, args}triples (spawn, timers, child specs) asmfa_refs,- literal atoms used as values (
module_refs) so supervision trees and plugs can be linked later, - literal arguments of selected framework calls (
init_literals).
The output contains only strings, integers, lists, tuples and maps, so it
can be cached and decoded with :erlang.binary_to_term(bin, [:safe]).
Summary
Functions
Encodes an Erlang term (for example an attribute value) in the string-based literal format used by summaries.
Builds a summary from abstract forms.
Builds the summary of a module without debug info from its :exports,
:imports and :attributes chunks.
Functions
@spec encode_term(term()) :: VulnCheck.Types.ModuleSummary.literal()
Encodes an Erlang term (for example an attribute value) in the string-based literal format used by summaries.
iex> VulnCheck.Beam.AbstractWalker.encode_term([protocol: Enumerable, for: List])
[{:tuple, [{:atom, "protocol"}, {:atom, "Elixir.Enumerable"}]}, {:tuple, [{:atom, "for"}, {:atom, "Elixir.List"}]}]
@spec summarize(module() | String.t(), [tuple()], keyword()) :: VulnCheck.Types.ModuleSummary.t()
Builds a summary from abstract forms.
Options:
:root_dir— project root used to make absolute source paths relative:attributes— the:attributeschunk (used when forms carry none):exports— the:exportschunk
@spec summarize_stripped(module() | String.t(), keyword()) :: VulnCheck.Types.ModuleSummary.t()
Builds the summary of a module without debug info from its :exports,
:imports and :attributes chunks.