# `VulnCheck.Diff`
[🔗](https://github.com/Voskan/vulncheck/blob/v1.0.1/lib/vulncheck/diff.ex#L1)

Incremental reporting for pull requests.

  * Baselines (`--baseline report.json`): findings whose fingerprint is
    in a previous JSON report are hidden. Fingerprints include the
    verdict, so an advisory that moves from `unreachable` to `reachable`
    is new, and the escalation is reported.
  * Git diffs (`--diff <ref>`): keep findings tied to changed packages or
    files. Keep every actionable finding unless a baseline establishes
    that it was already known. A current witness alone cannot establish
    the verdict at the base revision.

Both fail open: when the baseline or the Git data cannot be read, every
finding is kept and a warning explains why.

# `apply_baseline`

```elixir
@spec apply_baseline(
  [VulnCheck.Types.Finding.t()],
  [map()],
  VulnCheck.Types.Workspace.t() | nil
) ::
  {[VulnCheck.Types.Finding.t()], [String.t()]}
```

Hides findings present in the baseline. Returns the remaining findings and
warnings (escalations, number of hidden findings).

# `baseline_document`

```elixir
@spec baseline_document(VulnCheck.Types.ScanReport.t()) :: map()
```

Serializable baseline document of a report.

# `baseline_step`

```elixir
@spec baseline_step(Path.t()) :: (list(), map() -&gt;
                              {list(), [String.t()], [String.t()]})
```

Scanner post-processing step for `--baseline`.

# `changed_packages`

```elixir
@spec changed_packages(VulnCheck.Types.Workspace.t(), String.t(), String.t()) ::
  {:ok, MapSet.t(String.t())} | {:error, term()}
```

Packages added or whose locked identity changed since `ref`.

# `diff_step`

```elixir
@spec diff_step(String.t()) :: (list(), map() -&gt; {list(), [String.t()], [String.t()]})
```

Scanner post-processing step for `--diff <ref>`.

# `package_identity`

```elixir
@spec package_identity(VulnCheck.Types.Workspace.t() | nil, String.t()) ::
  String.t() | nil
```

Stable identity of a locked package for baseline comparisons.

# `read_baseline`

```elixir
@spec read_baseline(Path.t()) :: {:ok, [map()]} | {:error, String.t()}
```

Reads a baseline or a full JSON report. Entries without enough evidence to
compare the version, severity and policy state cannot hide a finding.

# `write_baseline`

```elixir
@spec write_baseline(VulnCheck.Types.ScanReport.t(), Path.t()) ::
  :ok | {:error, term()}
```

Writes the baseline of a report to `path`.

---

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