toolexec

package
v0.46.2 Latest Latest
Warning

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

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

Documentation

Overview

Package toolexec runs the external tools Draugr orchestrates, and reports what it ran.

It exists so that every external invocation — scanners today, SBOM generation and whatever comes next — narrates itself the same way. Without that, a run is a black box: you can see that something failed but not the command, the directory, how long it took, or what the tool itself said about it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, dir string, argv []string) ([]byte, error)

Run executes argv and returns its stdout. dir sets the working directory; empty inherits the current one. Some tools resolve their target relative to the working directory rather than from an argument (gosec loads Go packages via `./...`), so for those the checkout has to be the cwd, not just a path passed in.

No shell is involved — exec.CommandContext, not "sh -c" — and argv is built from typed config by the caller, never from user shell input.

func RunWithEnv added in v0.45.0

func RunWithEnv(ctx context.Context, dir string, argv, env []string) ([]byte, error)

RunWithEnv is Run with extra environment variables layered over the parent's, each "K=V".

A tool that shells out to another tool cannot be told which context to work in through argv — kube-bench invokes kubectl itself, and kubectl takes its cluster from the environment. This is how a scanner points such a tool at the right target rather than whatever the machine happens to be configured for.

Types

This section is empty.

Jump to

Keyboard shortcuts

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