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 ¶
const ( CategoryScanner = "scanner" CategoryUtility = "utility" )
Tool categories.
Variables ¶
This section is empty.
Functions ¶
func Catalog ¶
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; "" = the download is the binary
}
Asset is one platform's download for an installable tool. When BinaryInArchive is empty the downloaded file is the binary itself (a bare release binary, e.g. cosign), not an archive.
type CosignSpec ¶ added in v0.13.0
type CosignSpec struct {
// ChecksumsURL is the upstream's signed checksums file, listing each asset's SHA-256.
ChecksumsURL string
// BundleURL is the Sigstore bundle (.sigstore.json) signing ChecksumsURL.
BundleURL string
// IdentityRegexp is the required signing certificate identity (--certificate-identity-regexp).
IdentityRegexp string
// OIDCIssuer is the required OIDC issuer (--certificate-oidc-issuer).
OIDCIssuer string
}
CosignSpec describes how to verify a tool release's provenance with cosign, for upstreams that publish a keyless signature over their checksums file. It is optional and additive: the SHA-256 pin remains the mandatory integrity floor; cosign proves the checksums file was signed by the upstream's expected release identity. Verification uses the cosign CLI (no Go sigstore dependency) and the new Sigstore bundle format.
type InstallSpec ¶ added in v0.8.0
type InstallSpec struct {
Binary string
Version string
Assets map[string]Asset
// Cosign, when set, verifies the release's provenance in addition to the SHA-256 pin.
// Nil for upstreams that publish no signature (e.g. gitleaks) — those stay SHA-256-only.
Cosign *CosignSpec
}
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
// SignatureVerified is true when an upstream cosign signature was verified (in addition
// to the always-checked SHA-256 pin).
SignatureVerified bool
// ProvenanceNote summarizes the signature outcome for reporting (e.g. why it was skipped);
// empty when the tool has no cosign provenance configured.
ProvenanceNote string
// AlreadyPresent is true when the pinned build was already installed and left untouched.
AlreadyPresent bool
}
Installed describes a successfully provisioned tool.
func Install ¶ added in v0.8.0
func Install(ctx context.Context, name, destDir string, client *http.Client, force bool) (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. Install provisions a pinned tool into destDir. A tool already present at exactly the pinned build is left alone unless force is set — see the install manifest below.
type LookPathFunc ¶
LookPathFunc resolves a binary name to a path (defaults to exec.LookPath).
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.
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
// Category groups the tool: "scanner" (backs a control) or "utility" (supporting tool
// like git or cosign). Shown in `tools list`.
Category string
// Optional marks a tool whose absence should not fail `doctor` — a nice-to-have that
// enhances behavior (e.g. cosign for signature verification) rather than a requirement.
Optional bool
}
Tool describes an external executable a scanner shells out to.