audit

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Timestamp     time.Time `json:"timestamp"`
	Event         EventType `json:"event"`
	Peer          string    `json:"peer,omitempty"`
	File          string    `json:"file,omitempty"`
	VarsChanged   int       `json:"vars_changed,omitempty"`
	DeliveryCount int       `json:"delivery_count,omitempty"`
	Method        string    `json:"method,omitempty"`
	Details       string    `json:"details,omitempty"`
	PrevHash      string    `json:"prev_hash,omitempty"`
	HMAC          string    `json:"hmac,omitempty"`
}

Entry is a single audit log entry with tamper-evident chaining.

type EventType

type EventType string

EventType identifies an audit event.

const (
	EventPush              EventType = "push"
	EventPull              EventType = "pull"
	EventInvite            EventType = "invite"
	EventJoin              EventType = "join"
	EventRevoke            EventType = "revoke"
	EventKeyRotate         EventType = "key_rotate"
	EventOwnershipTransfer EventType = "ownership_transfer"
	EventConflictResolved  EventType = "conflict_resolved"
	EventBackup            EventType = "backup"
	EventRestore           EventType = "restore"
)

type Logger

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

Logger is an append-only, tamper-evident audit log.

func NewLogger

func NewLogger() (*Logger, error)

NewLogger creates a new audit logger and loads the previous chain hash.

func (*Logger) FilterByEvent

func (l *Logger) FilterByEvent(event EventType, limit int) ([]Entry, error)

FilterByEvent returns entries of a specific event type.

func (*Logger) FilterByPeer

func (l *Logger) FilterByPeer(peer string, limit int) ([]Entry, error)

FilterByPeer returns entries for a specific peer.

func (*Logger) Log

func (l *Logger) Log(entry Entry) error

Log appends a tamper-evident event to the audit log.

func (*Logger) Read

func (l *Logger) Read(limit int) ([]Entry, error)

Read returns all audit entries, newest first, after verifying integrity.

func (*Logger) Verify

func (l *Logger) Verify() error

Verify checks the on-disk audit log without returning entries.

Jump to

Keyboard shortcuts

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