audit

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: EUPL-1.2 Imports: 11 Imported by: 0

Documentation

Overview

Package audit provides infrastructure adapters for structured audit trail persistence. The FileAuditTrailWriter appends JSONL entries to a local file using O_APPEND atomic writes.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuditRecordTooLarge = errors.New("audit record exceeds size limit")
	ErrAuditWriterClosed   = errors.New("audit writer is closed")
)

Functions

func NewWriterFromEnv added in v0.11.2

func NewWriterFromEnv() (ports.AuditTrailWriter, func(), error)

NewWriterFromEnv creates a FileAuditTrailWriter based on the AWF_AUDIT_LOG env var. Returns (nil, noop, nil) when AWF_AUDIT_LOG=off. Returns a writer at the default XDG path when AWF_AUDIT_LOG is empty. The caller must defer the returned cleanup func.

Types

type FileAuditTrailWriter

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

FileAuditTrailWriter appends JSONL audit entries to a local file. Each bounded record is appended in one Write, protected against concurrent Close.

func NewFileAuditTrailWriter

func NewFileAuditTrailWriter(path string) (*FileAuditTrailWriter, error)

NewFileAuditTrailWriter opens or creates the audit log file at path. Creates parent directories as needed. File permissions are 0o600.

func (*FileAuditTrailWriter) Close

func (w *FileAuditTrailWriter) Close() error

Close flushes and closes the underlying file. Safe to call multiple times.

func (*FileAuditTrailWriter) Write

Write marshals event to JSONL and appends it to the audit file. If the serialized entry exceeds maxAuditRecordSize bytes, input values are truncated iteratively (longest first) until the entry fits, and InputsTruncated is set.

Jump to

Keyboard shortcuts

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