# `VulnCheck.Types.MFA`
[🔗](https://github.com/Voskan/vulncheck/blob/v1.0.1/lib/vulncheck/types/mfa.ex#L1)

A `Module.function/arity` reference stored entirely as strings.

Advisory feeds and third-party `.beam` files mention thousands of module and
function names. Converting them to atoms would let untrusted input exhaust the
BEAM atom table, so every symbol handled by the analyzer is kept as a canonical
string:

  * Elixir modules keep their BEAM name, e.g. `"Elixir.Plug.Conn.Query"`.
  * Erlang modules keep their plain name, e.g. `"cow_http_hd"`.

Atoms that already exist (for example those read from compiled `.beam` chunks)
are converted with `Atom.to_string/1`, which never creates new atoms.

# `t`

```elixir
@type t() :: %VulnCheck.Types.MFA{
  arity: non_neg_integer(),
  function: String.t(),
  module: String.t()
}
```

# `compare`

```elixir
@spec compare(t(), t()) :: :lt | :eq | :gt
```

Orders two MFAs deterministically (module, function, arity).

# `display_module`

```elixir
@spec display_module(String.t()) :: String.t()
```

Formats a canonical module name for display (`"Plug.Conn"` or `":cowlib"`).

# `elixir_module?`

```elixir
@spec elixir_module?(String.t()) :: boolean()
```

Returns `true` when the canonical module name belongs to an Elixir module.

# `format`

```elixir
@spec format(t()) :: String.t()
```

Formats an MFA for humans: `Plug.Conn.Query.decode/4` or `:cow_http_hd.parse/1`.

# `new`

```elixir
@spec new(atom() | String.t(), atom() | String.t(), non_neg_integer()) :: t()
```

Builds an MFA from a module (atom or string), function (atom or string) and arity.

# `normalize_module`

```elixir
@spec normalize_module(binary() | atom()) :: String.t()
```

Normalizes a module name to its canonical BEAM string.

    iex> VulnCheck.Types.MFA.normalize_module("Plug.Conn")
    "Elixir.Plug.Conn"

    iex> VulnCheck.Types.MFA.normalize_module("'cow_http_hd'")
    "cow_http_hd"

    iex> VulnCheck.Types.MFA.normalize_module(:"Elixir.Plug.Conn")
    "Elixir.Plug.Conn"

# `parse_routine`

```elixir
@spec parse_routine(binary()) :: {:ok, t()} | :error
```

Parses a routine string as published in EEF CNA `programRoutines`, GHSA
advisories or written by humans.

Supported notations:

    'Elixir.Plug.Conn.Query':decode/4
    hex_http_httpc:http_options/2
    'cow_http_hd':parse/1
    Ash.Actions.Aggregate.run/4
    :cow_http_hd.parse/1

Returns `:error` when the string has no explicit arity or is malformed.
No atoms are created.

    iex> VulnCheck.Types.MFA.parse_routine("'Elixir.Plug.Conn.Query':decode/4")
    {:ok, %VulnCheck.Types.MFA{module: "Elixir.Plug.Conn.Query", function: "decode", arity: 4}}

    iex> VulnCheck.Types.MFA.parse_routine("Ash.read")
    :error

# `to_tuple`

```elixir
@spec to_tuple(t()) :: {String.t(), String.t(), non_neg_integer()}
```

Converts an MFA to a `{module, function, arity}` tuple of strings.

---

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