# `VulnCheck.Feeds.Merge`
[🔗](https://github.com/Voskan/vulncheck/blob/v1.0.1/lib/vulncheck/feeds/merge.ex#L1)

Folds advisories that describe the same vulnerability of the same package
into one advisory.

The OSV Hex feed carries both the Erlang Ecosystem Foundation record
(`EEF-CVE-…`) and the GitHub record (`GHSA-…`) of most vulnerabilities, each
listing the CVE identifier as an alias. Advisories of one package whose
identifier sets (id, aliases and the CVE derived from them) overlap are
merged transitively:

  * the canonical id is the first of `EEF-CVE-*`, `CVE-*`, `GHSA-*`, then
    any other id (ties broken alphabetically); every other identifier
    becomes an alias;
  * a version is affected when any merged record says so: ranges and
    explicit versions are united, and a record affecting every version
    contributes an open range;
  * routines, modules, CWEs and references are united; the highest CVSS
    score and severity win;
  * summary and details prefer the canonical record. An OTP restriction
    is retained only when every merged record agrees.

The result is deterministic for any input order.

# `merge`

```elixir
@spec merge([VulnCheck.Types.Advisory.t()]) :: [VulnCheck.Types.Advisory.t()]
```

Merges overlapping advisories. Advisories without overlap are returned
unchanged; the output is sorted by package and canonical id.

---

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