audit

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package audit provides a definition of an audit event and an standard inteface to register events being triggered. Other packages may provide implementations of this interface to ship audit events to different destinations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auditor

type Auditor interface {
	// Call at shutdown to cleanly close the audit destination
	io.Closer

	// Audit event
	// source indicates the area that the event was triggered by
	// eventType indicates the specific event that occured
	// identity specifies the identity of the user that triggered this event, typically this is <role>/<cn>
	// contextID specifies the request ContextID that the event was triggered in [this can be used for cross service correlation of logs]
	// raftIndex indicates the index# of the raft log in RAFT that the event occured in [if applicable]
	// message contains any additional information about this event that is eventType specific
	Audit(
		source string,
		eventType string,
		identity string,
		contextID string,
		raftIndex uint64,
		message string)
}

Auditor defines an interface that can receive information about audit events

type Collector

type Collector struct {
	Destination Auditor
	// contains filtered or unexported fields
}

Collector is an Auditor that collects audit events in memory and sends them to the supplied destination Auditor when Submit is called. This can be useful for collecting up a set of audit events that aren't true until some later condition is verified [e.g. an Update to DB was successfull]

func (*Collector) Audit

func (c *Collector) Audit(source string,
	eventType string,
	identity string,
	contextID string,
	raftIndex uint64,
	message string)

Audit records a new Auditable event, its kept in memory until Submit() is called at which point it is sent to the Destination auditor

func (*Collector) Close

func (c *Collector) Close() error

Close will remove any collected events from this collector.

func (*Collector) Submit

func (c *Collector) Submit(raftIndex uint64)

Submit will flush all collected events to date to the Destination auditor. if raftIndex > 0 the submitted events will reflect that raftIndex, otherwise the original raftIndex is preserved.

type EventType

type EventType interface {
	ID() int
	String() string
}

EventType defines a specific event from the Source

type RaftIndexer

type RaftIndexer interface {
	// SetRaftIndex allows the raft index to be potentially updated
	// it returns true if the index was succesfully updated, false if
	// not. [typically impls should only allow it be set if it wasn't
	// previously set]
	SetRaftIndex(i uint64) bool
}

RaftIndexer identifies Event implementations that allow the raft index to be set

type Source

type Source interface {
	ID() int
	String() string
}

Source declares the general area that the audit event was raised from

Directories

Path Synopsis
Package log provides an implmentation of Auditer that writes to local disk files
Package log provides an implmentation of Auditer that writes to local disk files

Jump to

Keyboard shortcuts

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