audit

package
v0.1.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"`
}

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