audit

package
v0.3.64 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Timestamp time.Time      `json:"timestamp"`
	Type      EventType      `json:"type"`
	Action    string         `json:"action"`
	Actor     string         `json:"actor,omitempty"`
	Resource  string         `json:"resource,omitempty"`
	Detail    string         `json:"detail,omitempty"`
	SourceIP  string         `json:"source_ip,omitempty"`
	Success   bool           `json:"success"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

Event is a single audit log entry.

type EventType

type EventType string

EventType classifies security-relevant audit events.

const (
	EventAuth         EventType = "auth"
	EventAuthFailure  EventType = "auth_failure"
	EventAdminOp      EventType = "admin_op"
	EventEscalation   EventType = "escalation"
	EventDataAccess   EventType = "data_access"
	EventConfigChange EventType = "config_change"
	EventComponentOp  EventType = "component_op"
)

type Logger

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

Logger records security-relevant audit events as structured JSON.

func NewLogger

func NewLogger(w io.Writer) *Logger

NewLogger creates an AuditLogger that writes JSON events to the given writer. If w is nil, it defaults to os.Stdout.

func (*Logger) Log

func (l *Logger) Log(_ context.Context, event