audit

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package audit records an immutable, structured trail of handled requests.

A Record is emitted per audited request through a pluggable Sink. Sink implementations live in subpackages (see sink/file); tamper-resistance (retention, WORM) is delegated to the storage records are shipped to (append-only file, WORM bucket, SIEM), not enforced in-process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	Time      time.Time     `json:"time"`
	RequestID string        `json:"request_id"`
	Username  string        `json:"username,omitempty"`
	ClientIP  string        `json:"client_ip"`
	Method    string        `json:"method"`
	Path      string        `json:"path"`
	Error     string        `json:"error,omitempty"`
	Status    int           `json:"status"`
	Duration  time.Duration `json:"duration_ns"`
}

Record is a single audit entry describing one handled request.

type Sink

type Sink interface {
	Log(ctx context.Context, r Record) error
	io.Closer
}

Sink persists audit records. Implementations must be safe for concurrent use.

func Nop

func Nop() Sink

Nop returns a Sink that discards every record.

Directories

Path Synopsis
sink
file
Package file implements an audit.Sink that appends records as newline-delimited JSON to a file, rotating the file by size.
Package file implements an audit.Sink that appends records as newline-delimited JSON to a file, rotating the file by size.
log
Package log implements an audit.Sink that writes records through a zap logger.
Package log implements an audit.Sink that writes records through a zap logger.

Jump to

Keyboard shortcuts

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