cmdgate

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cmdgate is the single decision point for whether a command may run on a host. It combines honey's deterministic command-risk analysis (which the LLM cannot override) with an optional OPA policy enforcer, so every caller — the recipe engine, the web API, and the MCP server — gates exec the same way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decide

func Decide(ctx context.Context, enforcer *policy.Enforcer, analysis commandrisk.Analysis, input map[string]any) (reason string, denied bool, err error)

Decide reports whether a single command/target is denied.

Built-in critical risk signals (mkfs, dd to a block device, recursive chmod of a system path, curl|sh, …) always deny, even when enforcer is nil — the secure-by-default floor. For non-critical commands, a nil enforcer allows; otherwise the enforcer evaluates input and a verdict of deny / require_approval / require_biometric denies in non-interactive callers with a clear reason.

analysis is the result of commandrisk.Analyze/AnalyzeStep for the command. input is the policy input map the caller builds (action, actor, command, target, …); it is passed to enforcer.Evaluate verbatim.

Types

type TargetDecision

type TargetDecision struct {
	Name   string
	Reason string
	Denied bool
}

TargetDecision is the risk+policy verdict for one target.

func AssessTargets

func AssessTargets(ctx context.Context, enforcer *policy.Enforcer, rawCommand, interpreter string, targets []TargetInput, summaryOnly bool) (analysis commandrisk.Analysis, decisions []TargetDecision, err error)

AssessTargets runs commandrisk.AnalyzeStep once for the given command, then calls Decide for each TargetInput. The shared analysis is returned so callers can surface it in dry-run UIs without repeating the parse.

When summaryOnly is true only the first target is evaluated — this matches dry-run / preview semantics where a representative verdict is enough. When summaryOnly is false every target is evaluated — this matches the runtime gate where per-host decisions are needed.

type TargetInput

type TargetInput struct {
	Name        string
	PolicyInput map[string]any
}

TargetInput carries the name and pre-built policy input map for one target. Callers build PolicyInput from their own host types; cmdgate stays ignorant of hosts.Record so the import graph stays clean.

Jump to

Keyboard shortcuts

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