policy

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package policy provides a hook interface for future policy engines (OPA, etc.). In the MVP, hooks are no-ops. The interface is designed for extensibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowAll

type AllowAll struct{}

AllowAll is the default no-op implementation that permits everything.

func (AllowAll) EvalCommand

func (AllowAll) EvalCommand(_ context.Context, _ uuid.UUID, _ string, _ []string) Decision

func (AllowAll) EvalFileAccess

func (AllowAll) EvalFileAccess(_ context.Context, _ uuid.UUID, _ string, _ bool) Decision

type Decision

type Decision struct {
	Allowed bool
	Reason  string
}

Decision is the outcome of a policy evaluation.

type DenyAll

type DenyAll struct{ Reason string }

DenyAll rejects every request with the given reason. Useful for tests.

func (DenyAll) EvalCommand

func (d DenyAll) EvalCommand(_ context.Context, _ uuid.UUID, _ string, _ []string) Decision

func (DenyAll) EvalFileAccess

func (d DenyAll) EvalFileAccess(_ context.Context, _ uuid.UUID, _ string, _ bool) Decision

type Hook

type Hook interface {
	// EvalCommand determines whether a command may execute in the given session.
	EvalCommand(ctx context.Context, sessionID uuid.UUID, command string, args []string) Decision
	// EvalFileAccess determines whether a file path may be accessed.
	EvalFileAccess(ctx context.Context, sessionID uuid.UUID, path string, write bool) Decision
}

Hook is the extension point for policy enforcement.

type OPAHook

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

OPAHook evaluates commands and file access against an embedded Rego policy. The module must live in package vaultrun and define:

allow_command (boolean) — whether the command may run
allow_file    (boolean) — whether the file path may be accessed
deny_reason   (string, optional) — human-readable denial message

func NewOPAHook

func NewOPAHook(ctx context.Context, module string) (*OPAHook, error)

NewOPAHook compiles a Rego module string into an OPAHook ready for evaluation.

func NewOPAHookFromFile

func NewOPAHookFromFile(ctx context.Context, path string) (*OPAHook, error)

NewOPAHookFromFile reads a Rego policy file and compiles it.

func (*OPAHook) EvalCommand

func (h *OPAHook) EvalCommand(ctx context.Context, sessionID uuid.UUID, command string, args []string) Decision

func (*OPAHook) EvalFileAccess

func (h *OPAHook) EvalFileAccess(ctx context.Context, sessionID uuid.UUID, path string, write bool) Decision

Jump to

Keyboard shortcuts

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