Search documentation of Metastatic

# Metastatic.Analysis.Taint.Result (Metastatic v0.2.0)

View Source

Result structure for taint analysis.

Contains information about taint flows from sources to sinks, identifying potential security issues from untrusted data.

## Fields

- `:has_taint_flows?` - Boolean indicating if taint flows were found
- `:taint_flows` - List of detected taint flow paths
- `:summary` - Human-readable summary of findings
- `:total_flows` - Count of taint flows
- `:by_risk` - Map of counts by risk level

## Examples

    iex> result = Metastatic.Analysis.Taint.Result.new([])
    iex> result.has_taint_flows?
    false

    iex> flows = [%{source: "input", sink: "eval", risk: :critical}]
    iex> result = Metastatic.Analysis.Taint.Result.new(flows)
    iex> result.has_taint_flows?
    true

# Summary

## Types

risk_level()
t()
taint_flow()

## Functions

new(taint_flows)

Creates a new result from a list of taint flows.

no_taint()

Creates a result with no taint flows.

to_map(result)

Converts result to JSON-compatible map.

# Types

# risk_level()

    @type risk_level() :: :critical | :high | :medium | :low

# t()

    @type t() :: %Metastatic.Analysis.Taint.Result{
      by_risk: %{required(risk_level()) => non_neg_integer()},
      has_taint_flows?: boolean(),
      summary: String.t(),
      taint_flows: [taint_flow()],
      total_flows: non_neg_integer()
    }

# taint_flow()

    @type taint_flow() :: %{
      source: String.t(),
      sink: String.t(),
      risk: risk_level(),
      path: [String.t()],
      recommendation: String.t()
    }

# Functions

# new(taint_flows)

    @spec new([taint_flow()]) :: t()

Creates a new result from a list of taint flows.

## Examples

    iex> Metastatic.Analysis.Taint.Result.new([])
    %Metastatic.Analysis.Taint.Result{has_taint_flows?: false, summary: "No taint flows detected"}

    iex> flows = [%{source: "input", sink: "eval", risk: :critical, path: [], recommendation: "sanitize"}]
    iex> result = Metastatic.Analysis.Taint.Result.new(flows)
    iex> result.has_taint_flows?
    true

# no_taint()

    @spec no_taint() :: t()

Creates a result with no taint flows.

## Examples

    iex> result = Metastatic.Analysis.Taint.Result.no_taint()
    iex> result.has_taint_flows?
    false

# to_map(result)

    @spec to_map(t()) :: map()

Converts result to JSON-compatible map.

## Examples

    iex> result = Metastatic.Analysis.Taint.Result.new([])
    iex> map = Metastatic.Analysis.Taint.Result.to_map(result)
    iex> is_map(map)
    true