hook

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hook implements bash command validation and approval logic.

Index

Constants

View Source
const SedSandboxAdvice = "Use 'sed --sandbox ...' to avoid a permission prompt."

SedSandboxAdvice is context advice provided when sed is run without sandbox.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandValidator

type CommandValidator func(args []string) Decision

CommandValidator inspects arguments for a specific command and returns a Decision.

type Decision

type Decision struct {
	Decision string `json:"decision,omitzero"`
	Context  string `json:"context,omitzero"`
}

Decision represents the outcome of inspecting a command.

func Allow

func Allow() Decision

Allow returns an affirmative approval decision.

func Prompt

func Prompt(context string) Decision

Prompt returns a fall-through decision, optionally carrying context advice.

func Validate

func Validate(cmd string) Decision

Validate inspects a shell command string and determines if auto-approval is permissible based on command structure, AST composition, and allowlists.

func (Decision) IsAllowed

func (d Decision) IsAllowed() bool

IsAllowed returns true if the decision permits command execution.

func (Decision) JSON

func (d Decision) JSON() ([]byte, error)

JSON serializes the decision to a JSON byte slice.

Jump to

Keyboard shortcuts

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