security

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package security provides a plugin-based security layer for evaluating events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check interface {
	// Name returns the unique identifier for this check.
	Name() string
	// Check evaluates the event and returns a result.
	Check(ctx context.Context, event *events.Event) (*CheckResult, error)
	// Enabled returns whether this check is currently active.
	Enabled() bool
}

Check defines the interface for security checks.

type CheckResult

type CheckResult struct {
	// Decision is the outcome of this check.
	Decision Decision
	// Reason is required for Block decisions, explaining why the action was blocked.
	Reason string
	// Guidance is optional advisory text for the agent.
	Guidance string
	// CheckName identifies which check produced this result.
	CheckName string
}

CheckResult represents the result of a single security check.

type Config

type Config struct {
	// FailOpen determines behavior when a check returns an error.
	// If true, check errors don't block (fail open).
	// If false, check errors cause blocking (fail closed).
	FailOpen bool
}

Config holds configuration options for the security evaluator.

type Decision

type Decision int

Decision represents the outcome of a security check.

const (
	// DecisionAllow allows the action to proceed.
	DecisionAllow Decision = iota
	// DecisionBlock blocks the action from proceeding.
	DecisionBlock
	// DecisionGuidance allows the action but provides advisory guidance.
	DecisionGuidance
)

func (Decision) String

func (d Decision) String() string

String returns the string representation of the decision.

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

Evaluator orchestrates security checks against events.

func New

func New(cfg *Config) *Evaluator

New creates a new security Evaluator with the given configuration.

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(ctx context.Context, event *events.Event) *Result

Evaluate runs all registered checks against the event and returns an aggregated result. Checks are evaluated in order, and evaluation stops immediately on a Block decision.

func (*Evaluator) RegisterCheck

func (e *Evaluator) RegisterCheck(check Check)

RegisterCheck adds a security check to the evaluator.

type Result

type Result struct {
	// FinalDecision is the overall decision after evaluating all checks.
	FinalDecision Decision
	// BlockReason is the reason if the action was blocked.
	BlockReason string
	// BlockedBy is the name of the check that blocked the action.
	BlockedBy string
	// Guidance contains aggregated guidance from all checks.
	Guidance []string
	// CheckResults contains the individual results from each check.
	CheckResults []*CheckResult
	// Error contains any error that occurred during evaluation.
	Error error
}

Result aggregates results from all security checks.

func NewAllowResult

func NewAllowResult() *Result

NewAllowResult creates a new Result with an Allow decision.

func (*Result) AggregatedGuidance

func (r *Result) AggregatedGuidance() string

AggregatedGuidance returns all guidance joined with newlines.

func (*Result) HasGuidance

func (r *Result) HasGuidance() bool

HasGuidance returns true if there is any guidance to provide.

func (*Result) IsAllowed

func (r *Result) IsAllowed() bool

IsAllowed returns true if the action is allowed (not blocked).

Jump to

Keyboard shortcuts

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