audit

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package audit provides audit logging with hash chain verification.

Index

Constants

View Source
const (
	ErrorCodeAuditRecordMalformed     = "E_AUDIT_RECORD_MALFORMED"
	ErrorCodeAuditChainBroken         = "E_AUDIT_CHAIN_BROKEN"
	ErrorCodeAuditRecordHashMismatch  = "E_AUDIT_RECORD_HASH_MISMATCH"
	ErrorCodeAuditRecordHashRecompute = "E_AUDIT_RECORD_HASH_RECOMPUTE_FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileAppender

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

FileAppender appends audit records to a JSONL file with hash chain.

func NewFileAppender

func NewFileAppender(path string) *FileAppender

NewFileAppender creates a new FileAppender.

func (*FileAppender) Append

func (a *FileAppender) Append(eventType model.AuditEventType, worktreeName string, snapshotID model.SnapshotID, details map[string]any) error

Append adds a new audit record to the log.

func (*FileAppender) EnsureAppendable

func (a *FileAppender) EnsureAppendable() error

EnsureAppendable verifies that the audit log can be safely extended.

func (*FileAppender) GetLastRecordHash

func (a *FileAppender) GetLastRecordHash() (model.HashValue, error)

GetLastRecordHash returns the hash of the last record in the log.

type IntegrityError

type IntegrityError struct {
	Code    string
	Line    int
	Message string
}

IntegrityError is returned when an audit log cannot be safely extended.

func (*IntegrityError) Error

func (e *IntegrityError) Error() string

type Issue

type Issue struct {
	Line      int
	Severity  string
	ErrorCode string
	Message   string
}

Issue describes an audit log integrity issue.

func VerifyFile

func VerifyFile(path string) ([]Issue, error)

VerifyFile verifies audit record hashes and hash-chain linkage.

Jump to

Keyboard shortcuts

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