VulnCheck.Config (VulnCheck v1.0.1)

Copy Markdown View Source

Scan configuration resolved from command-line flags, .vulncheck.exs and built-in defaults (in that order of precedence).

.vulncheck.exs is a declarative keyword list. It is parsed with VulnCheck.Literal, which never evaluates code and never creates atoms: only literals, whitelisted option values and module aliases are accepted.

[
  env: :prod,
  fail_on: :potentially_reachable,
  min_severity: :low,
  fail_on_retired: true,
  configured_adapters: [tesla: Tesla.Adapter.Mint],
  extra_entrypoints: [{MyApp.ReleaseTasks, :migrate, 0}],
  ignore_file: ".vulncheck.ignore",
  require_ignore_reason: true,
  require_ignore_expiry: true,
  cache_dir: nil,
  cache_ttl_seconds: 3600
]

Summary

Functions

Supported adapter families for configured_adapters.

The OptionParser aliases understood by every scanning command.

Supported --fail-on tiers.

Supported output formats.

Builds a configuration from CLI arguments and the project's .vulncheck.exs.

Absolute path of the ignore file.

Loads a .vulncheck.exs file (or any declarative config file) and merges it into the given configuration.

Parses a declarative configuration file without evaluating it.

Absolute path of the scanned project.

Returns the severity rank used for threshold comparisons (critical = 4). Unknown severities rank as :critical (fail-safe).

The OptionParser switches understood by every scanning command.

Types

fail_on()

@type fail_on() :: :reachable | :potentially_reachable | :any | :none

format()

@type format() ::
  :terminal
  | :json
  | :markdown
  | :sarif
  | :github
  | :gitlab
  | :cyclonedx
  | :openvex

min_severity()

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

t()

@type t() :: %VulnCheck.Config{
  args: [String.t()],
  baseline: String.t() | nil,
  beam_timeout: pos_integer(),
  bundle: String.t() | nil,
  cache_dir: String.t() | nil,
  cache_ttl_seconds: non_neg_integer(),
  check_retired: boolean(),
  color: boolean(),
  config_file: String.t() | nil,
  configured_adapters: %{required(atom()) => [String.t()]},
  diff: String.t() | nil,
  env: :prod | :dev | :test,
  extra_entrypoints: [VulnCheck.Types.MFA.t()],
  fail_on: fail_on(),
  fail_on_retired: boolean(),
  feed_selection: map() | nil,
  feed_snapshot: String.t() | nil,
  forbid_new_suppressions: boolean(),
  force: boolean(),
  format: format(),
  ignore_file: String.t(),
  max_beam_bytes: pos_integer(),
  max_beam_files: pos_integer(),
  max_beam_heap_bytes: pos_integer(),
  max_feed_age_seconds: non_neg_integer() | nil,
  min_severity: min_severity(),
  offline: boolean(),
  otp_version: String.t() | nil,
  output: String.t() | nil,
  project_dir: String.t(),
  quiet: boolean(),
  require_ignore_expiry: boolean(),
  require_ignore_reason: boolean(),
  sarif: String.t() | nil,
  sbom: String.t() | nil,
  show_unreachable: boolean(),
  vex: String.t() | nil,
  write_baseline: String.t() | nil
}

Functions

adapter_families()

@spec adapter_families() :: [atom()]

Supported adapter families for configured_adapters.

aliases()

@spec aliases() :: keyword()

The OptionParser aliases understood by every scanning command.

fail_on_values()

@spec fail_on_values() :: [fail_on()]

Supported --fail-on tiers.

formats()

@spec formats() :: [format()]

Supported output formats.

from_cli_and_file(argv, opts \\ [])

@spec from_cli_and_file([String.t()], keyword()) :: {:ok, t()} | {:error, String.t()}

Builds a configuration from CLI arguments and the project's .vulncheck.exs.

Precedence: CLI flags > .vulncheck.exs > defaults.

Options:

  • :cwd — directory used to resolve a relative --project-dir (default: File.cwd!/0)
  • :extra_switches — additional OptionParser switches accepted by a subcommand
  • :allow_args — when true, positional arguments are kept in config.args instead of being rejected

ignore_path(config)

@spec ignore_path(t()) :: String.t()

Absolute path of the ignore file.

load_file(config)

@spec load_file(t()) :: {:ok, t()} | {:error, String.t()}

Loads a .vulncheck.exs file (or any declarative config file) and merges it into the given configuration.

parse_config_file(path)

@spec parse_config_file(Path.t()) ::
  {:ok, VulnCheck.Literal.lterm()} | {:error, String.t()}

Parses a declarative configuration file without evaluating it.

project_root(config)

@spec project_root(t()) :: String.t()

Absolute path of the scanned project.

severity_rank(arg1)

@spec severity_rank(atom()) :: non_neg_integer()

Returns the severity rank used for threshold comparisons (critical = 4). Unknown severities rank as :critical (fail-safe).

switches()

@spec switches() :: keyword()

The OptionParser switches understood by every scanning command.