tools

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package tools describes the external command-line scanners Draugr orchestrates and detects whether they are installed. It backs `draugr doctor` — an explicit preflight so a missing tool is reported up front with an install hint, instead of surfacing as a buried "executable file not found" error mid-scan.

Detection only ever reads the environment (looks on PATH, runs a version probe). It never downloads or installs anything — provisioning is a separate, opt-in step.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Catalog

func Catalog() map[string]Tool

Catalog returns the external tools Draugr's built-in scanners use, keyed by binary name. Several scanners share one binary (trivy backs images, sca, and iac), so the catalog is keyed by the binary rather than the scanner.

Types

type LookPathFunc

type LookPathFunc func(string) (string, error)

LookPathFunc resolves a binary name to a path (defaults to exec.LookPath).

type RunFunc

type RunFunc func(ctx context.Context, argv []string) ([]byte, error)

RunFunc executes argv and returns its output (defaults to running the command).

type Status

type Status struct {
	Tool    Tool
	Found   bool
	Path    string
	Version string
	// Err is set when the tool was found but the version probe failed (non-fatal).
	Err error
}

Status is the outcome of detecting a Tool.

func Detect

func Detect(ctx context.Context, t Tool, lookPath LookPathFunc, run RunFunc) Status

Detect reports whether a tool is on PATH and, if so, its version. lookPath and run are injectable for testing; nil uses the real environment.

type Tool

type Tool struct {
	// Binary is the executable name looked up on PATH, e.g. "trivy".
	Binary string
	// VersionArgs prints the tool's version, e.g. ["--version"]. Empty skips the probe.
	VersionArgs []string
	// InstallHint tells the user how or where to install the tool when it's missing.
	InstallHint string
}

Tool describes an external executable a scanner shells out to.

func All

func All() []Tool

All returns the catalog's tools sorted by binary name, for a full environment check when no Saga narrows the set.

Jump to

Keyboard shortcuts

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