diagnostics

package
v0.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 32 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CapabilityAvailable   = "available"
	CapabilityUnavailable = "unavailable"
	CapabilityUnverified  = "unverified"
)

Capability states.

View Source
const (
	PurposeScan   = "scan"
	PurposeAgent  = "agent"
	PurposeServer = "server"
)

Purposes `doctor --for` accepts.

View Source
const (
	ScopedOK       = "ok"
	ScopedDegraded = "degraded"
	ScopedNotReady = "not_ready"
	ScopedWarning  = "warning"
	ScopedSkipped  = "skipped"
)

Scoped check statuses. A counted check's status feeds the verdict: not_ready > degraded > ok; warning and skipped never do.

View Source
const CheckStatusUnverified = "unverified"

CheckStatusUnverified is a check whose configuration is complete but whose live dependency was not contacted (an agent provider behind an endpoint): `doctor --for agent` probes it.

View Source
const TemplatesMarkerFile = nucleitemplates.MarkerFile

TemplatesMarkerFile is written into the nuclei templates directory by the archive install (nucleitemplates.Install): which release it is, its archive digest, and when it was installed, so doctor can say "stale" from a fact rather than a directory mtime.

Variables

Purposes lists the valid --for values.

Functions

func AllCheckIDs added in v0.5.7

func AllCheckIDs() []string

AllCheckIDs lists every check id Run can report from the CLI (queue needs Deps.Queue and is the server's), in Report.Checks order: what an Include predicate and a `doctor --only` token choose among.

func CheckIDForToken added in v0.5.7

func CheckIDForToken(token string, checks []Check) string

CheckIDForToken maps a `doctor --only` token (a check id, or a --fix key or alias such as chrome, nuclei, nuclei-templates) to its check id, or "".

func HasFixableIssues

func HasFixableIssues(r *Report) bool

HasFixableIssues reports whether the report contains any failing checks that the auto-fix harness knows how to handle. Drives the `--fix` hint in the doctor CLI — there's no point suggesting --fix when nothing in the report is fixable.

pi and piolium are treated as optional when claude (Path A) is available — the audit mode already has a working driver, so a missing Path B alone should not trigger the "re-run with --fix" hint. A missing bun is also ignored when npm is present, since the JS installs fall back to npm.

func NucleiTemplatesDir

func NucleiTemplatesDir(settings *config.Settings) string

NucleiTemplatesDir resolves the nuclei templates directory from settings or the ~/nuclei-templates default. Exported so the `update` command resolves the same path as the doctor checks and fixes.

func ResolveFixKey

func ResolveFixKey(name string) string

ResolveFixKey is the exported form of resolveAlias: it maps a user-supplied --only token (e.g. "chrome", "nuclei") to its canonical fix key (e.g. "chromium", "nuclei-templates"). The doctor CLI uses it to render a focused view of just the components named in --only.

func ScopedOnlyCheckIDs added in v0.5.7

func ScopedOnlyCheckIDs() []string

ScopedOnlyCheckIDs are the check ids (`doctor --only` tokens) only a purpose-scoped report runs; "target" selects target_dns, target_tcp and target_tls with it. "proxy" is in both reports: see ProxyCheck.

func ScopedSelectorID added in v0.5.7

func ScopedSelectorID(id string) string

ScopedSelectorID is the --only id that selects the scoped check id: "target" for its target_* sub-checks, else id itself.

func TemplatesAge added in v0.5.7

func TemplatesAge(dir string) (time.Duration, bool)

TemplatesAge is how old the templates install is: the pinned marker's install time when present (TemplatesMarkerFile), else the directory's mtime.

func ValidPurpose added in v0.5.7

func ValidPurpose(p string) bool

ValidPurpose reports whether p is a --for value.

Types

type AgentCheck

type AgentCheck struct {
	Status       Status   `json:"status"`
	Name         string   `json:"name"`
	Binary       string   `json:"binary,omitempty"`
	Protocol     string   `json:"protocol,omitempty"`
	PingResponse string   `json:"ping_response,omitempty"`
	Message      string   `json:"message,omitempty"`
	Details      []string `json:"details,omitempty"`
	Tip          string   `json:"tip,omitempty"`
	// Unverified marks a provider reached over an endpoint whose
	// configuration is complete but which was not contacted: plain doctor
	// does not probe it, `doctor --for agent` does. Endpoint names it.
	Unverified bool   `json:"unverified,omitempty"`
	Endpoint   string `json:"endpoint,omitempty"`
}

AgentCheck holds the outcome of the agent backend check.

type AuditPathStatus

type AuditPathStatus struct {
	OK      bool     // true when every component this path needs is healthy
	Reasons []string // one line per failing component (e.g. "claude: not found in PATH")
}

AuditPathStatus describes one of the two driver paths under "Audit mode" in the doctor renderer. Paths are independent — either one being OK is enough to consider the audit mode usable.

func AuditPathA

func AuditPathA(r *Report) AuditPathStatus

AuditPathA reports the status of the claude/audit driver path used by `vigolium agent audit --driver=audit`. Both the `claude` CLI and the embedded vigolium-audit binary are required; when `agent.audit.enabled=false` the path is treated as unavailable (the user has explicitly opted out).

func AuditPathB

func AuditPathB(r *Report) AuditPathStatus

AuditPathB reports the status of the piolium driver path used by `vigolium agent audit --driver=piolium`. Needs pi (the runtime) and the piolium Pi extension loaded. pi is installed via bun or npm, but once present it's a standalone binary — neither bun nor npm is required at audit time, so they are not part of this path's required set.

type Capabilities added in v0.5.7

type Capabilities struct {
	Scan           string `json:"scan"`
	Spidering      string `json:"spidering"`
	KnownIssueScan string `json:"known_issue_scan"`
	OutOfBand      string `json:"out_of_band"`
	Agent          string `json:"agent"`
	Audit          string `json:"audit"`
}

Capabilities says what still works, so a degraded verdict names its cost.

type Check added in v0.5.7

type Check struct {
	ID string `json:"id"`
	// Group is the section the check belongs to: core, native_scan, agent,
	// audit, tools or coding_agent.
	Group string `json:"group"`
	// Status is ok, warning, error, unverified or skipped.
	Status  string   `json:"status"`
	Message string   `json:"message,omitempty"`
	Affects []string `json:"affects,omitempty"`
	FixArgv []string `json:"fix_argv,omitempty"`
	Tip     string   `json:"tip,omitempty"`
	Details []string `json:"details,omitempty"`
	// Source names the setting the check tested and the layer that set it
	// ("oast.server_url from env:VIGOLIUM_OAST_DOMAIN"), on a failing check.
	Source string `json:"source,omitempty"`
}

Check is one flat row of a report: what `doctor -j` lists as items and what `--only` selects. The nested Report stays the server's /diagnostics shape; this is a view over it.

type CheckResult

type CheckResult struct {
	Status  Status   `json:"status"`
	Message string   `json:"message,omitempty"`
	Details []string `json:"details,omitempty"` // verbose-only diagnostic details
	Tip     string   `json:"tip,omitempty"`     // remediation hint shown at all verbosity levels
}

CheckResult holds the outcome of a single diagnostic check.

func ProxyCheck added in v0.5.7

func ProxyCheck(route *proxyenv.Route, source string) *CheckResult

ProxyCheck is the full report's proxy row: which proxy every request goes through, where it was configured, and whether it accepts a connection. Loopback targets are not exempt from it (an explicit proxy URL, unlike Go's environment resolver, proxies localhost too).

type Deps

type Deps struct {
	DB *database.DB
	// DBErr carries the error from opening the database when DB is nil. The
	// CLI populates this so checkDatabase can surface real connect failures
	// (refused, auth failed, unknown host) instead of "not configured".
	DBErr error
	// ConfigErr carries the error from loading the configuration file when
	// Settings fell back to defaults. doctor exists to REPORT broken state, so a
	// config it could not read must be a failed check here rather than a log line
	// nobody sees next to a report that says everything is fine.
	ConfigErr error
	// ConfigPath is the file the CLI actually resolved, so a report run with
	// --config names the file it read rather than the default location. Empty
	// falls back to the default path.
	ConfigPath string
	Queue      queue.Queue
	Settings   *config.Settings
	// ProbeBrowserLaunch, when set, makes the chromium check actually launch the
	// resolved browser headless (catching a binary that passes --version but
	// crashes on real startup). It spawns a browser process (~1-2s), so only the
	// one-shot CLI paths (doctor, first-run init) enable it; the server
	// /diagnostics endpoint leaves it off to stay a cheap, poll-safe readout.
	ProbeBrowserLaunch bool
	// ProbeNetwork, when set, lets the OAST check resolve the interactsh server
	// and open one TLS connection to it (3s budget, no registration). Like
	// ProbeBrowserLaunch it is set by the CLI doctor only; the server
	// /diagnostics endpoint leaves it off so a poll never touches the network.
	ProbeNetwork bool
	// Include, when set, selects the checks to run by check id (the ids
	// Report.Checks lists; `doctor --only`): a check it refuses never runs —
	// no chromium launch, no jstangle extraction, no OAST resolution — and is
	// absent from the report, whose Status is the verdict over the checks that
	// ran. nil runs every check. The PATH lookups for the tools other than
	// chromium always run: they are cheap, and the pi/piolium tips and the
	// --fix dependency graph read them.
	Include func(id string) bool
}

Deps provides the dependencies needed to run diagnostics. All fields are optional — nil values are handled gracefully.

type FixOptions added in v0.5.7

type FixOptions struct {
	// AssumeYes consents to every vendor install (doctor --fix --yes).
	AssumeYes bool
	// Confirm, when set, is asked per vendor install not named in --only
	// (an interactive prompt); nil means no consent.
	Confirm func(label, source string) bool
	// DryRun lists the installs that would run (Planned rows) and runs none.
	DryRun bool
}

FixOptions governs consent for VendorScript installs.

type FixResult

type FixResult struct {
	Key     string `json:"key"`
	Label   string `json:"label"`
	Success bool   `json:"success"`
	Message string `json:"message"`
	// Skipped marks an install that was not attempted because it pipes a
	// vendor installer into a shell and consent was not given.
	Skipped bool `json:"skipped,omitempty"`
	// Planned marks a --dry-run row: the install that would run, how, where
	// to and roughly how large.
	Planned     bool   `json:"planned,omitempty"`
	Method      string `json:"method,omitempty"`
	Source      string `json:"source,omitempty"`
	Destination string `json:"destination,omitempty"`
	Size        string `json:"size,omitempty"`
}

FixResult holds the outcome of a single fix attempt.

func RunFixes

func RunFixes(ctx context.Context, report *Report, settings *config.Settings, only []string) []FixResult

RunFixes attempts to fix failing checks. If only is non-empty, only those items (and their required dependencies) are fixed.

pi and piolium are skipped by default when claude (Path A) is available — audit mode already has a working driver, so we don't want a bare `--fix` to pull in the Path B stack as well. Users who want both drivers can still opt in with `--fix --only piolium` (or `--only pi`).

The standalone bun install is skipped by default when npm is present — npm-equipped hosts use npm for the global installs. `--only bun` force- installs bun regardless.

Installs that pipe a vendor script into a shell or add global agent tooling (VendorScript: bun, claude, agent-browser, pi, piolium) are skipped unless named in only; RunFixesWith adds --yes and an interactive confirmation.

func RunFixesWith added in v0.5.7

func RunFixesWith(ctx context.Context, report *Report, settings *config.Settings, only []string, opts FixOptions) []FixResult

RunFixesWith is RunFixes with consent options for vendor installs.

type Report

type Report struct {
	Status           Status                  `json:"status"` // "ready", "degraded", "not_ready"
	Timestamp        string                  `json:"timestamp"`
	Config           *CheckResult            `json:"config"`
	Scope            *CheckResult            `json:"scope"`
	OAST             *CheckResult            `json:"oast"`
	Database         *CheckResult            `json:"database"`
	Initialized      *CheckResult            `json:"initialized"`
	Queue            *CheckResult            `json:"queue,omitempty"`
	Agent            *AgentCheck             `json:"agent"`
	Browser          *CheckResult            `json:"browser"`
	SessionsDir      *CheckResult            `json:"sessions_dir"`
	EmbeddedBinaries map[string]*CheckResult `json:"embedded_binaries,omitempty"`
	Audit            *CheckResult            `json:"audit,omitempty"`   // omitted when audit integration is disabled
	Piolium          *CheckResult            `json:"piolium,omitempty"` // soft check — feature-gates audit --driver=piolium
	Tools            map[string]*ToolCheck   `json:"tools"`
	TemplatesDir     *CheckResult            `json:"templates_dir"`
	NucleiTemplates  *CheckResult            `json:"nuclei_templates"`
	// Skill is the coding-agent skill install check. The CLI fills it in after
	// Run (it needs the binary's version and embedded bundle), so the server's
	// /diagnostics leaves it nil. It never moves Status: a stale skill does
	// not stop a scan.
	Skill *CheckResult `json:"skill,omitempty"`
}

Report is the complete diagnostic report.

func Run

func Run(deps Deps) *Report

Run performs all diagnostic checks and returns a report.

func (*Report) Capabilities added in v0.5.7

func (r *Report) Capabilities() Capabilities

Capabilities derives what works from the report.

func (*Report) Checks added in v0.5.7

func (r *Report) Checks() []Check

Checks flattens the report into one row per check, in report order: core, native scan, agent, audit, tools, coding agent.

type ScopedCheck added in v0.5.7

type ScopedCheck struct {
	ID      string   `json:"id"`
	Status  string   `json:"status"`
	Counts  bool     `json:"counts"`
	Affects []string `json:"affects,omitempty"`
	Message string   `json:"message,omitempty"`
	FixArgv []string `json:"fix_argv,omitempty"`
}

ScopedCheck is one row of a scoped report.

type ScopedDeps added in v0.5.7

type ScopedDeps struct {
	Settings *config.Settings
	// Stateless skips the database check (-S scans use a temporary store).
	Stateless bool
	// Proxy is the --proxy URL. With it unset, the environment's proxies
	// (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY, NO_PROXY) are checked instead.
	Proxy string
	// Getenv reads the environment for the proxy variables (os.Getenv when
	// nil).
	Getenv func(string) string
	// Target, when set, adds DNS/TCP/TLS checks for that URL (doctor -t).
	Target string
	// DBDir is the database directory checked for free space ("" skips it).
	DBDir string
	// Include selects the scoped checks to run by id, as Deps.Include does
	// for the report: an unselected probe (proxy dial, disk, open-file limit,
	// target, agent endpoint) never runs. nil runs every check.
	Include func(id string) bool
}

ScopedDeps are the inputs a scoped report needs beyond the full Report.

type ScopedReport added in v0.5.7

type ScopedReport struct {
	For    string        `json:"for"`
	Status Status        `json:"status"` // ready | degraded | not_ready
	Checks []ScopedCheck `json:"checks"`
}

ScopedReport is the readiness of one purpose.

func Scoped added in v0.5.7

func Scoped(purpose string, r *Report, deps ScopedDeps) (*ScopedReport, error)

Scoped derives the readiness of purpose from a full report plus the scoped probes. Unknown purposes return an error.

func (*ScopedReport) Narrow added in v0.5.7

func (s *ScopedReport) Narrow(keep func(id string) bool)

Narrow keeps the checks keep admits and recomputes the verdict over them, so a report narrowed with --only says whether THOSE checks are ready rather than counting checks nobody asked about (and that may not have run).

type Status

type Status string

Status represents the state of a diagnostic check.

const (
	StatusOK      Status = "ok"
	StatusWarning Status = "warning"
	StatusError   Status = "error"
)

type TemplatesMarker added in v0.5.7

type TemplatesMarker = nucleitemplates.Marker

TemplatesMarker is the content of TemplatesMarkerFile.

func ReadTemplatesMarker added in v0.5.7

func ReadTemplatesMarker(dir string) (*TemplatesMarker, error)

ReadTemplatesMarker reads dir's marker.

type ToolCheck

type ToolCheck struct {
	Status  Status   `json:"status"`
	Path    string   `json:"path,omitempty"`
	Message string   `json:"message,omitempty"`
	Details []string `json:"details,omitempty"`
	Tip     string   `json:"tip,omitempty"`
}

ToolCheck holds the outcome of a third-party tool check.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL