Documentation
¶
Overview ¶
Package exec registers the "exec" query provider, which runs a command and reads its JSON stdout as rows.
The provider executes whatever command a profile names, so it is opt-in: it is registered with every host through query/providers, but refuses to run until the host sets EnabledProperty (-P query.exec.enabled=true), or calls Enable because it trusts every profile it runs. A server that accepts inline profiles opts in only when it trusts every caller that can post one.
Index ¶
Constants ¶
const EnabledProperty = "query.exec.enabled"
EnabledProperty opts a host in to running exec profiles; it defaults to off.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExecOptions ¶
type ExecOptions struct {
// Command is the executable, resolved on PATH. It is never run through a
// shell, so templated arguments cannot inject commands.
Command string `json:"command"`
// Args are the command's arguments, passed as argv.
Args []string `json:"args,omitempty"`
// Env are variables set for the command.
Env []types.EnvVar `json:"env,omitempty"`
// PassthroughEnv names host variables handed to the command; the rest of
// the host environment is withheld.
PassthroughEnv []string `json:"passthroughEnv,omitempty"`
// Dir is the working directory; empty runs in a fresh temporary directory.
Dir string `json:"dir,omitempty"`
// Format is how stdout is read: json (exactly one value), ndjson (one
// object per line) or auto (one or more values, the default).
Format string `json:"format,omitempty"`
// JSONPath extracts an inner array/object from each value, e.g. "$.items".
JSONPath string `json:"jsonpath,omitempty"`
// Timeout is a Go duration after which the command is killed; empty waits
// for the command or the request's own deadline.
Timeout string `json:"timeout,omitempty"`
}
ExecOptions are decoded from ProviderRequest.Options.
func (ExecOptions) Validate ¶
func (o ExecOptions) Validate() error
Validate refuses options the provider cannot run, before any process starts.