tools

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 16 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 BinDir added in v0.8.0

func BinDir() (string, error)

BinDir is Draugr's managed tool directory, ~/.draugr/bin.

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.

func Installable added in v0.8.0

func Installable() []string

Installable returns the names of the tools `tools install` can provision, sorted.

func SemgrepPipxCommand added in v0.8.0

func SemgrepPipxCommand() string

SemgrepPipxCommand returns the recommended pinned install command for Semgrep, which is a Python package rather than a standalone binary.

func SemgrepVersion added in v0.8.0

func SemgrepVersion() string

SemgrepVersion is the pinned Semgrep version.

Types

type Asset added in v0.8.0

type Asset struct {
	URL             string
	SHA256          string
	BinaryInArchive string // name of the binary within the .tar.gz
}

Asset is one platform's download for an installable tool.

type InstallSpec added in v0.8.0

type InstallSpec struct {
	Binary  string
	Version string
	Assets  map[string]Asset
}

InstallSpec pins an installable tool to a version and its per-platform assets, keyed by "GOOS/GOARCH" (e.g. "linux/amd64").

func Spec added in v0.8.0

func Spec(name string) (InstallSpec, bool)

Spec returns the pinned install spec for a tool.

type Installed added in v0.8.0

type Installed struct {
	Name    string
	Version string
	Path    string
}

Installed describes a successfully provisioned tool.

func Install added in v0.8.0

func Install(ctx context.Context, name, destDir string, client *http.Client) (Installed, error)

Install downloads the pinned build of name, verifies its SHA-256, extracts the binary, and installs it into destDir with an executable bit. client may be nil (a default is used). The download is verified before anything is written, and the binary is placed atomically.

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