VulnCheck.Report.Formatter behaviour (VulnCheck v1.0.1)

Copy Markdown View Source

Contract of report renderers plus helpers shared by them.

Summary

Functions

Findings grouped by verdict, preserving report order.

Identifier shown to humans: the CVE alias when there is one.

The specific recommended fixed release, or nil.

Formats a CVSS score with one decimal.

Advisory web page for a finding.

Text of a trace hop: the function, followed by what an activation hop does (MyApp.Application.start/2 starts Bandit), or the note alone when the activation is not a function.

Location of a trace hop (file:line), or nil.

Formats an MFA in Elixir or Erlang notation.

Trace hops with their step numbers. The activation hop is step 0, so the entrypoint is step 1 in every chain.

Location used to annotate a finding. Chooses the first trace hop in the project source tree, or the package entry in the lockfile.

Returns true for a path inside the project's own source tree (relative, outside deps/ and _build/).

Trace hops that can be annotated in the project, with normalized paths.

Human description of a reason code.

Findings a machine-readable report emits: active actionable findings, plus unreachable ones when show_unreachable is set.

Numeric severity used by code scanning dashboards: the CVSS score or, when unknown, a representative score of the severity band (unknown counts as critical).

Upper-case severity label.

Severity with CVSS score, e.g. HIGH · CVSS 7.5.

Identifier with the other names of the vulnerability, for example CVE-2026-39804 (GHSA-frh3-6pv6-rc8j). Identifiers that only wrap the CVE (such as EEF-CVE-…) are left out.

Callbacks

render(t, t)

Functions

by_verdict(findings)

@spec by_verdict([VulnCheck.Types.Finding.t()]) :: %{
  required(atom()) => [VulnCheck.Types.Finding.t()]
}

Findings grouped by verdict, preserving report order.

display_id(finding)

@spec display_id(VulnCheck.Types.Finding.t()) :: String.t()

Identifier shown to humans: the CVE alias when there is one.

fix_text(finding)

@spec fix_text(VulnCheck.Types.Finding.t()) :: String.t() | nil

The specific recommended fixed release, or nil.

format_score(score)

@spec format_score(number()) :: String.t()

Formats a CVSS score with one decimal.

help_uri(finding)

@spec help_uri(VulnCheck.Types.Finding.t()) :: String.t()

Advisory web page for a finding.

hop(trace_hop)

Text of a trace hop: the function, followed by what an activation hop does (MyApp.Application.start/2 starts Bandit), or the note alone when the activation is not a function.

location(trace_hop)

@spec location(VulnCheck.Types.TraceHop.t()) :: String.t() | nil

Location of a trace hop (file:line), or nil.

mfa(mfa)

@spec mfa(VulnCheck.Types.MFA.t() | nil) :: String.t() | nil

Formats an MFA in Elixir or Erlang notation.

numbered(hops)

Trace hops with their step numbers. The activation hop is step 0, so the entrypoint is step 1 in every chain.

primary_location(finding, workspace)

@spec primary_location(
  VulnCheck.Types.Finding.t(),
  VulnCheck.Types.Workspace.t() | nil
) ::
  {String.t(), pos_integer()}

Location used to annotate a finding. Chooses the first trace hop in the project source tree, or the package entry in the lockfile.

project_file?(file)

@spec project_file?(String.t() | nil) :: boolean()

Returns true for a path inside the project's own source tree (relative, outside deps/ and _build/).

project_locations(hops, workspace)

@spec project_locations(
  [VulnCheck.Types.TraceHop.t()],
  VulnCheck.Types.Workspace.t() | nil
) :: [
  VulnCheck.Types.TraceHop.t()
]

Trace hops that can be annotated in the project, with normalized paths.

reason_label(reason)

@spec reason_label(VulnCheck.Types.Finding.reason()) :: String.t()

Human description of a reason code.

reported(findings, show_unreachable)

Findings a machine-readable report emits: active actionable findings, plus unreachable ones when show_unreachable is set.

security_severity(finding)

@spec security_severity(VulnCheck.Types.Finding.t()) :: String.t()

Numeric severity used by code scanning dashboards: the CVSS score or, when unknown, a representative score of the severity band (unknown counts as critical).

severity_label(severity)

@spec severity_label(VulnCheck.Types.Advisory.severity()) :: String.t()

Upper-case severity label.

severity_text(finding, separator \\ " · ")

@spec severity_text(VulnCheck.Types.Finding.t(), String.t()) :: String.t()

Severity with CVSS score, e.g. HIGH · CVSS 7.5.

title_id(finding)

@spec title_id(VulnCheck.Types.Finding.t()) :: String.t()

Identifier with the other names of the vulnerability, for example CVE-2026-39804 (GHSA-frh3-6pv6-rc8j). Identifiers that only wrap the CVE (such as EEF-CVE-…) are left out.