audit

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailJSON

func DetailJSON(m map[string]any) string

DetailJSON is a helper to create a JSON detail string from a map.

Types

type Entry

type Entry struct {
	ID        int64     `json:"id"`
	Timestamp time.Time `json:"timestamp"`
	Actor     string    `json:"actor"`
	Action    string    `json:"action"`
	Resource  string    `json:"resource"`
	Detail    string    `json:"detail"`
	Outcome   string    `json:"outcome"`
}

Entry is a single audit log record.

type Log

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

Log provides append-only audit logging backed by SQLite.

func New

func New(db *sql.DB) *Log

New creates a new audit Log.

func (*Log) Append

func (l *Log) Append(ctx context.Context, actor, action, resource, detail, outcome string) error

Append writes a single audit entry. Detail should be a JSON string.

func (*Log) Query

func (l *Log) Query(ctx context.Context, actor, action, from, to string, limit int) ([]Entry, error)

Query returns audit entries matching the given filters. All filter parameters are optional (empty string = no filter).

func (*Log) QuerySummary

func (l *Log) QuerySummary(ctx context.Context, from, to string) (*Summary, error)

QuerySummary returns aggregated audit statistics for the given time range.

type Summary

type Summary struct {
	TotalEntries    int            `json:"total_entries"`
	ActionCounts    map[string]int `json:"action_counts"`
	OutcomeCounts   map[string]int `json:"outcome_counts"`
	UniqueActors    int            `json:"unique_actors"`
	UniqueResources int            `json:"unique_resources"`
}

Summary is an aggregated view of audit activity.

Jump to

Keyboard shortcuts

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