# `VulnCheck.Beam.Loader`
[🔗](https://github.com/Voskan/vulncheck/blob/v1.0.1/lib/vulncheck/beam/loader.ex#L1)

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.

# `result`

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

# `analyze_binary`

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

Summarizes `.beam` contents held in memory.

# `load_dirs`

```elixir
@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`

```elixir
@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`

```elixir
@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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
