audit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package audit writes the console's append-only JSONL audit trail. One record per event; never secrets and never row data.

Index

Constants

View Source
const (
	EventLogin     = "login"
	EventPolicy    = "policy"    // policy change, applied or refused (see Decision)
	EventRefused   = "refused"   // plan refused by the classifier, the tier or the weight check
	EventApproved  = "approved"  // the human approved
	EventDenied    = "denied"    // the human denied
	EventTimeout   = "timeout"   // approval timed out
	EventAbandoned = "abandoned" // the client left while its approval was pending
	EventAuto      = "auto"      // auto-approved under --skip-permissions
	EventCatalog   = "catalog"   // catalog read
	EventLogout    = "logout"
)

Events, spec §15.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

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

Log appends records to <stateDir>/locksql/audit.log. The file is opened in append mode for each record, so it is never truncated and never held open.

func Open

func Open(stateDir string) (*Log, error)

Open prepares the audit log under stateDir: the directory is 0700 and the file 0600 (Unix), created if missing; existing content is kept.

func (*Log) Path

func (l *Log) Path() string

Path is the audit log file.

func (*Log) Write

func (l *Log) Write(rec Record) error

Write appends rec as one JSON line with the current time in RFC 3339.

type Record

type Record struct {
	Event      string   `json:"event"`
	Profile    string   `json:"profile,omitempty"`
	Engine     string   `json:"engine,omitempty"`
	Host       string   `json:"host,omitempty"`
	DB         string   `json:"db,omitempty"`
	DBUser     string   `json:"db_user,omitempty"`
	Class      string   `json:"class,omitempty"`
	SQL        string   `json:"sql,omitempty"`
	Verdict    string   `json:"verdict,omitempty"`
	Decision   string   `json:"decision,omitempty"`
	Error      string   `json:"error,omitempty"`
	Rows       int64    `json:"rows,omitempty"`
	Affected   int64    `json:"affected,omitempty"`
	DurationMS int64    `json:"duration_ms,omitempty"`
	Truncated  bool     `json:"truncated,omitempty"`
	Unmasked   bool     `json:"unmasked,omitempty"`
	Warnings   []string `json:"warnings,omitempty"`
}

Record is one audit event. It has no field able to hold a password or row data: Error must already be sanitised by the caller.

Jump to

Keyboard shortcuts

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