VulnCheck.Beam.Loader (VulnCheck v1.0.1)

Copy Markdown View Source

Reads compiled .beam files without loading them into the VM.

Chunks are read with :beam_lib.chunks/2. Modules with debug info are summarized from their abstract code by VulnCheck.Beam.AbstractWalker; stripped modules (:no_abstract_code) fall back to their :imports table and are flagged with has_debug_info: false.

Summaries are cached by the SHA-256 of the .beam contents (and the project root used for relative source paths), so unchanged modules are never analyzed twice. Files are processed in parallel.

Summary

Functions

Summarizes .beam contents held in memory.

Loads all .beam files of the given {package_or_nil, ebin_dir} pairs. When two directories define the same module, the first one wins.

Summarizes one .beam file. Returns {:ok, summary, :cached | :analyzed}.

Loads every module of the workspace: root applications, dependencies and consolidated protocols (which replace the unconsolidated ones).

Types

result()

@type result() :: %{
  :modules => %{required(String.t()) => VulnCheck.Types.ModuleSummary.t()},
  :warnings => [String.t()],
  :artifact_issues => [{String.t() | nil, String.t()}],
  :stats => %{required(atom()) => non_neg_integer()},
  optional(:profile_matches) => boolean()
}

Functions

analyze_binary(bytes, opts \\ [])

@spec analyze_binary(binary(), keyword()) ::
  {:ok, VulnCheck.Types.ModuleSummary.t(), :cached | :analyzed}
  | {:error, term()}

Summarizes .beam contents held in memory.

load_dirs(dirs, opts \\ [])

@spec load_dirs([{String.t() | nil, String.t()}], keyword()) :: result()

Loads all .beam files of the given {package_or_nil, ebin_dir} pairs. When two directories define the same module, the first one wins.

load_file(path, opts \\ [])

@spec load_file(String.t(), keyword()) ::
  {:ok, VulnCheck.Types.ModuleSummary.t(), :cached | :analyzed}
  | {:error, term()}

Summarizes one .beam file. Returns {:ok, summary, :cached | :analyzed}.

load_workspace(workspace, config \\ nil, opts \\ [])

@spec load_workspace(
  VulnCheck.Types.Workspace.t(),
  VulnCheck.Config.t() | nil,
  keyword()
) :: result()

Loads every module of the workspace: root applications, dependencies and consolidated protocols (which replace the unconsolidated ones).

Options: :cache (a VulnCheck.Config, defaults to config; false disables caching), :max_concurrency.