BAM.Limits (BAM v0.1.0)

Copy Markdown View Source

Caps applied while decoding untrusted BAM, BGZF, and index bytes.

Each field is a maximum this library will accept before it returns {:error, %BAM.Error{category: :resource_limit}}. BGZF uncompressed size is also hard-capped at 65_536 by the SAM specification. That cap is not configurable.

Defaults are large enough for current reference genomes and long reads, and small enough that a hostile length field cannot force an unbounded allocation.

Summary

Functions

Default caps.

Merges a keyword or map of overrides onto the defaults.

Types

t()

@type t() :: %BAM.Limits{
  max_aux_array: pos_integer(),
  max_aux_bytes: pos_integer(),
  max_bins: pos_integer(),
  max_chunks: pos_integer(),
  max_cigar_ops: pos_integer(),
  max_header_bytes: pos_integer(),
  max_index_bytes: pos_integer(),
  max_linear_index: pos_integer(),
  max_read_name_bytes: pos_integer(),
  max_record_bytes: pos_integer(),
  max_records: pos_integer() | nil,
  max_reference_name_bytes: pos_integer(),
  max_references: pos_integer()
}

Functions

default()

@spec default() :: t()

Default caps.

merge(limits)

@spec merge(keyword() | map() | t()) :: {:ok, t()} | {:error, BAM.Error.t()}

Merges a keyword or map of overrides onto the defaults.

Unknown keys are an invalid argument. Values must be positive integers, except :max_records, which may be nil.