forward

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrForwardFailed is returned when audit log forwarding to an external
	// system fails and the configured on_fail policy is "block".
	ErrForwardFailed = errors.New("failed to forward audit log to external system")
)

Functions

This section is empty.

Types

type ENISABackend

type ENISABackend struct {
	QueuePath string
}

ENISABackend implements Forwarder for the ENISA single reporting platform. In v2.0, this is a stub backend that writes to a local queue file.

func NewENISABackend

func NewENISABackend(queuePath string) *ENISABackend

NewENISABackend creates a new ENISABackend stub.

func (*ENISABackend) Name

func (e *ENISABackend) Name() string

Name returns the backend name.

func (*ENISABackend) Send

func (e *ENISABackend) Send(_ context.Context, entry model.AuditEntry) error

Send appends the entry to the local queue file.

type ForwardMultiplexer

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

ForwardMultiplexer allows sending to multiple forwarders at once

func NewForwardMultiplexer

func NewForwardMultiplexer(backends []Forwarder, onFail string) *ForwardMultiplexer

NewForwardMultiplexer creates a multiplexer that sends each audit entry to all configured backends. The onFail policy ("block", "warn", "best_effort") controls behaviour when a backend returns an error.

func (*ForwardMultiplexer) Dispatch

func (m *ForwardMultiplexer) Dispatch(ctx context.Context, entry model.AuditEntry) error

Dispatch sends the entry to all configured backends.

type Forwarder

type Forwarder interface {
	Send(ctx context.Context, entry model.AuditEntry) error
	Name() string
}

Forwarder represents a destination backend for audit log entries.

type NotificationEvent

type NotificationEvent struct {
	EventName  string
	Acceptance *model.Acceptance
	OldHash    string
	NewHash    string
}

NotificationEvent represents an event that triggers a notification.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, event NotificationEvent) error
	Name() string
}

Notifier defines the interface for notification channels (Webhook, Email)

type NotifyMultiplexer

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

NotifyMultiplexer allows sending notifications via multiple channels

func NewNotifyMultiplexer

func NewNotifyMultiplexer(channels []Notifier) *NotifyMultiplexer

NewNotifyMultiplexer creates a multiplexer that dispatches notification events to all configured notifier channels.

func (*NotifyMultiplexer) Dispatch

func (m *NotifyMultiplexer) Dispatch(ctx context.Context, event NotificationEvent) []error

Dispatch sends the notification event to all configured channels.

type SyslogBackend

type SyslogBackend struct {
	Address  string
	Protocol string
	Facility syslog.Priority
	// contains filtered or unexported fields
}

SyslogBackend implements Forwarder for Syslog.

func NewSyslogBackend

func NewSyslogBackend(address, protocol, facility string) (*SyslogBackend, error)

NewSyslogBackend creates a new SyslogBackend that connects to the given syslog server using the specified protocol (tcp/udp) and facility.

func (*SyslogBackend) Name

func (b *SyslogBackend) Name() string

Name returns the backend identifier "syslog".

func (*SyslogBackend) Send

func (b *SyslogBackend) Send(_ context.Context, entry model.AuditEntry) error

Send marshals the audit entry to JSON and forwards it via syslog.

type WebhookNotifier

type WebhookNotifier struct {
	URL         string
	TemplateDir string
	Events      map[string]bool
	// contains filtered or unexported fields
}

WebhookNotifier implements Notifier for HTTP webhooks.

func NewWebhookNotifier

func NewWebhookNotifier(url, tmplDir string, events []string) *WebhookNotifier

NewWebhookNotifier creates a new WebhookNotifier that sends HTTP POST requests with rendered templates for the specified event types.

func (*WebhookNotifier) Name

func (w *WebhookNotifier) Name() string

Name returns the notifier identifier "webhook".

func (*WebhookNotifier) Notify

func (w *WebhookNotifier) Notify(ctx context.Context, event NotificationEvent) error

Notify sends a templated HTTP POST notification for the given event. Returns nil if the event type is not in the configured event set.

Jump to

Keyboard shortcuts

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