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

audit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: EUPL-1.2 Imports: 14 Imported by: 0

Documentation

Overview

Package audit writes a hash-chained JSONL audit log and verifies it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(dir string) (string, int, error)

Verify walks all *.jsonl files in name order and checks the hash chain. It returns the last hash and the number of lines. A missing or empty dir yields ("sha256:0", 0, nil). Errors name <file>:<line>.

Types

type Level

type Level string

Level selects how much of each payload is stored.

const (
	Full     Level = "full"
	Metadata Level = "metadata"
)

type Writer

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

Writer appends chained, fsynced lines. Safe for concurrent use, and across processes sharing the same dir (exclusive flock on <dir>/.lock per Write; the chain tail is re-read from disk inside the lock).

func Open

func Open(dir string, level Level, redact func(string) string) (*Writer, error)

Open creates dir (0700, chmod'ed if it already exists), chmods existing *.jsonl files to 0600 and checks the chain tail. An unparsable last line is an error.

func (*Writer) Close

func (w *Writer) Close() error

Close releases the lock file.

func (*Writer) Write

func (w *Writer) Write(e event.Event) error

Write appends e to the log and fsyncs. After a failed write the Writer is broken and every later Write fails (fail closed).

Jump to

Keyboard shortcuts

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