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

audit

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Overview

Package audit provides audit logging for the platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeParameters

func SanitizeParameters(params map[string]any) map[string]any

SanitizeParameters removes sensitive parameters from the event.

Types

type Config

type Config struct {
	Enabled       bool
	LogToolCalls  bool
	RetentionDays int
}

Config configures audit logging.

type Event

type Event struct {
	ID           string         `json:"id"`
	Timestamp    time.Time      `json:"timestamp"`
	DurationMS   int64          `json:"duration_ms"`
	RequestID    string         `json:"request_id"`
	UserID       string         `json:"user_id"`
	UserEmail    string         `json:"user_email,omitempty"`
	Persona      string         `json:"persona,omitempty"`
	ToolName     string         `json:"tool_name"`
	ToolkitKind  string         `json:"toolkit_kind,omitempty"`
	ToolkitName  string         `json:"toolkit_name,omitempty"`
	Connection   string         `json:"connection,omitempty"`
	Parameters   map[string]any `json:"parameters,omitempty"`
	Success      bool           `json:"success"`
	ErrorMessage string         `json:"error_message,omitempty"`
}

Event represents an auditable event.

func NewEvent

func NewEvent(toolName string) *Event

NewEvent creates a new audit event.

func (*Event) WithConnection

func (e *Event) WithConnection(connection string) *Event

WithConnection adds connection information to the event.

func (*Event) WithParameters

func (e *Event) WithParameters(params map[string]any) *Event

WithParameters adds parameters to the event.

func (*Event) WithPersona

func (e *Event) WithPersona(persona string) *Event

WithPersona adds persona information to the event.

func (*Event) WithRequestID

func (e *Event) WithRequestID(requestID string) *Event

WithRequestID adds a request ID to the event.

func (*Event) WithResult

func (e *Event) WithResult(success bool, errorMsg string, durationMS int64) *Event

WithResult adds result information to the event.

func (*Event) WithToolkit

func (e *Event) WithToolkit(kind, name string) *Event

WithToolkit adds toolkit information to the event.

func (*Event) WithUser

func (e *Event) WithUser(userID, email string) *Event

WithUser adds user information to the event.

type EventType

type EventType string

EventType categorizes audit events.

const (
	// EventTypeToolCall is a tool invocation event.
	EventTypeToolCall EventType = "tool_call"

	// EventTypeAuth is an authentication event.
	EventTypeAuth EventType = "auth"

	// EventTypeAdmin is an administrative event.
	EventTypeAdmin EventType = "admin"
)

type Logger

type Logger interface {
	// Log records an audit event.
	Log(ctx context.Context, event Event) error

	// Query retrieves audit events matching the filter.
	Query(ctx context.Context, filter QueryFilter) ([]Event, error)

	// Close releases resources.
	Close() error
}

Logger defines the interface for audit logging.

type QueryFilter

type QueryFilter struct {
	StartTime   *time.Time
	EndTime     *time.Time
	UserID      string
	ToolName    string
	ToolkitKind string
	Success     *bool
	Limit       int
	Offset      int
}

QueryFilter defines criteria for querying audit events.

Directories

Path Synopsis
Package postgres provides PostgreSQL storage for audit logs.
Package postgres provides PostgreSQL storage for audit logs.

Jump to

Keyboard shortcuts

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