audit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package audit writes secret-safe structured broker audit events.

Index

Constants

View Source
const (
	DecisionAllowed   = "allowed"
	DecisionRefused   = "refused"
	DecisionGrantUsed = "grant-used"
)

Decision values used by broker request audit events.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Time                  time.Time         `json:"time"`
	Broker                string            `json:"broker"`
	Client                string            `json:"client"`
	Operation             string            `json:"operation"`
	Target                string            `json:"target"`
	Attrs                 map[string]string `json:"attrs,omitempty"`
	Decision              string            `json:"decision"`
	Reason                string            `json:"reason"`
	MatchedRuleIDs        []string          `json:"matched_rule_ids,omitempty"`
	MatchedDenyRuleIDs    []string          `json:"matched_deny_rule_ids"`
	MatchedGrantRuleIDs   []string          `json:"matched_grant_rule_ids"`
	MatchedAllowRuleIDs   []string          `json:"matched_allow_rule_ids"`
	MatchedRequestRuleIDs []string          `json:"matched_request_rule_ids"`
	GrantID               string            `json:"grant_id"`
	PlanDigest            string            `json:"plan_digest"`
	Approver              string            `json:"approver,omitempty"`
	Status                int               `json:"status,omitempty"`
	UpstreamStatus        int               `json:"upstream_status"`
	ErrorCode             string            `json:"error_code,omitempty"`
	Extensions            map[string]string `json:"extensions,omitempty"`
}

Event is one broker audit event.

type Recorder added in v0.2.0

type Recorder interface {
	Record(Event) error
}

Recorder accepts one secret-safe audit event.

type Writer

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

Writer writes audit events as JSON lines.

func New

func New(out io.Writer) *Writer

New returns an audit Writer.

func (*Writer) Record

func (w *Writer) Record(event Event) error

Record writes one audit event.

func (*Writer) WithClock

func (w *Writer) WithClock(now func() time.Time) *Writer

WithClock sets the clock used for events with no Time.

Jump to

Keyboard shortcuts

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