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

sqlaudit

package
v0.13.0 Latest Latest
Warning

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

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

Documentation

Overview

Package sqlaudit is locksql's audit record on lockkit's audit log: one JSONL record per event, never secrets and never row data. The record keeps locksql 0.8's fields in their order, so a line written today is the one written before lockkit for the same event, then, in hub mode, the hub fields, and last lockkit's prev_hash (the hash chain, see audit.Verify). Readers of the old format ignore both.

Index

Constants

View Source
const (
	EventLogin     = audit.EventLogin
	EventPolicy    = audit.EventPolicy
	EventRefused   = audit.EventRefused
	EventApproved  = audit.EventApproved
	EventDenied    = audit.EventDenied
	EventTimeout   = audit.EventTimeout
	EventAbandoned = audit.EventAbandoned
	EventAuto      = audit.EventAuto
	EventRun       = audit.EventRun
	EventCatalog   = audit.EventCatalog
	EventMode      = audit.EventMode
	EventResults   = audit.EventResults
	EventUnmask    = audit.EventUnmask
	EventLogout    = audit.EventLogout
	// EventPending is a request handed to lockhub (hub mode): its ticket
	// is in the reason.
	EventPending = audit.EventPending
	// EventRenew is an expired ticket asked again (hub mode): renewed by
	// a new ticket, named in the reason, or refused.
	EventRenew = audit.EventRenew
	// EventConfigImport is a `locksql config import`, applied or refused.
	EventConfigImport = "config_import"
)

Events: lockkit's console events.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log = audit.Log

Log is lockkit's audit log.

func Open

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

Open opens locksql's audit log: <stateDir>/locksql/audit.log.

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"`
	SSHHost    string `json:"ssh_host,omitempty"`
	SSHHostKey string `json:"ssh_host_key,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"`
	// Code is the refusal code of a refused record (package refusal), and
	// Span where the refusal points in the statement, when known.
	Code       string        `json:"code,omitempty"`
	Span       *refusal.Span `json:"span,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"`
	// Intent is the agent's one-line reason for a plan (untrusted text,
	// like SQL), kept on every record of that plan.
	Intent string `json:"intent,omitempty"`
	// Reason is the human's reason for a denial, escaped.
	Reason string `json:"reason,omitempty"`
	// Approval is how the human approved: "session" (typed in a login
	// session of the console account), "desktop+typed" (typed in a desktop
	// window, level 1) or "desktop+fingerprint" (level 2).
	Approval string `json:"approval,omitempty"`
	// The client behind a request, from the kernel's peer credentials:
	// set on the records of client requests only. PeerUID is nil when
	// unknown (uid 0 is root); PeerUser is the account name when it
	// resolves. The process name is the agent's choice and is not kept.
	PeerUID  *int   `json:"peer_uid,omitempty"`
	PeerPID  int    `json:"peer_pid,omitempty"`
	PeerUser string `json:"peer_user,omitempty"`
	// Scope, Profiles and AllowLoosen describe a config import: the scope
	// written (user or project), the profiles it changes and whether
	// loosening was allowed. Never a value.
	Scope       string   `json:"scope,omitempty"`
	Profiles    []string `json:"profiles,omitempty"`
	AllowLoosen bool     `json:"allow_loosen,omitempty"`
	// The hub's decision behind a record, in hub mode only (lockkit's
	// audit.Base names): the ticket ID, who answered it and on which
	// facade, and the hub's signature of the decision.
	Ticket   string           `json:"ticket,omitempty"`
	Approver *ticket.Approver `json:"approver,omitempty"`
	Facade   string           `json:"facade,omitempty"`
	HubSig   string           `json:"hub_sig,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.

func (Record) AuditEvent

func (r Record) AuditEvent() string

AuditEvent implements lockkit's audit.Record.

Jump to

Keyboard shortcuts

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