Help us shape the future of Go! Take the 2026 Go Developer Survey

audit

package
v0.86.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 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 Event)

Log records an audit event. It is safe for concurrent use.

func (*Logger) LogAdminOp

func (l *Logger) LogAdminOp(ctx context.Context, actor, action, resource, detail string)

LogAdminOp records an administrative operation.

func (*Logger) LogAuth

func (l *Logger) LogAuth(ctx context.Context, actor, sourceIP string, success bool, detail string)

LogAuth records an authentication event.

func (*Logger) LogComponentOp

func (l *Logger) LogComponentOp(ctx context.Context, actor, action, componentID, detail string, success bool)

LogComponentOp records a dynamic component lifecycle operation.

func (*Logger) LogConfigChange

func (l *Logger) LogConfigChange(ctx context.Context, actor, resource, detail string)

LogConfigChange records a configuration change event.

func (*Logger) LogDataAccess

func (l *Logger) LogDataAccess(ctx context.Context, actor, resource, detail string)

LogDataAccess records a data access event.

func (*Logger) LogEscalation

func (l *Logger) LogEscalation(ctx context.Context, actor, action, detail string, success bool)

LogEscalation records a privilege escalation event.

Jump to

Keyboard shortcuts

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