sqlaudit

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 4 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 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"
	// EventGrant is a grant activated from its decided ticket (or the
	// activation refused); EventGrantEnd is its end: revoked, expired,
	// the session's end or a policy that no longer allows it. Both carry
	// the grant id and the hub's signature of its decision.
	EventGrant    = "grant"
	EventGrantEnd = "grant_end"
)

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"`
	// Grant is the grant behind a record: its activation, its end and
	// every run it covered (with the decision's HubSig); GrantScope is
	// its scope in words (database, tables, duration, budget).
	Grant string `json:"grant,omitempty"`
	// AutoRule is the profile's auto rule for the action of a record
	// ("auto.write = ask", locksql#185): what made its ticket asked or
	// left to lox run's auto mode, or the refusal of a denied action.
	// DecidedBy is what decided the ticket, from the hub's version-2
	// decision: "human" or "auto:<rule id>".
	AutoRule   string `json:"auto_rule,omitempty"`
	DecidedBy  string `json:"decided_by,omitempty"`
	GrantScope string `json:"grant_scope,omitempty"`
	// StatementsUsed and BytesUsed are what a grant used, on its
	// grant_end record (with Rows); set there only, 0 included.
	StatementsUsed *int64 `json:"statements_used,omitempty"`
	BytesUsed      *int64 `json:"bytes_used,omitempty"`
	// Managed is the sha256 of the company's managed file in force when
	// the record was made (lockkit's audit.Base name), "" for none.
	Managed string `json:"managed,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