audit

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auditor

type Auditor interface {
	AuditRequest(req Request)
}

func SetupAuditor

func SetupAuditor(ctx context.Context, logger *slog.Logger, disableAuditLogs bool, logProxySocketPath string, sessionID uuid.UUID, confinedProcessName string) (Auditor, error)

SetupAuditor creates and configures the appropriate auditors based on the provided configuration. It always includes a LogAuditor for stderr logging, and conditionally adds a SocketAuditor if audit logs are enabled and the workspace agent's log proxy socket exists.

type LogAuditor

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

LogAuditor implements proxy.Auditor by logging to slog

func NewLogAuditor

func NewLogAuditor(logger *slog.Logger) *LogAuditor

NewLogAuditor creates a new LogAuditor

func (*LogAuditor) AuditRequest

func (a *LogAuditor) AuditRequest(req Request)

AuditRequest logs the request using structured logging

type MultiAuditor

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

MultiAuditor wraps multiple auditors and sends audit events to all of them.

func NewMultiAuditor

func NewMultiAuditor(auditors ...Auditor) *MultiAuditor

NewMultiAuditor creates a new MultiAuditor that sends to all provided auditors.

func (*MultiAuditor) AuditRequest

func (m *MultiAuditor) AuditRequest(req Request)

AuditRequest sends the request to all wrapped auditors.

type Request

type Request struct {
	Method  string
	URL     string // The fully qualified request URL (scheme, domain, optional path).
	Host    string
	Allowed bool
	Rule    string // The rule that matched (if any)

	// SequenceNumber is the sequence number assigned to this audit event
	// by the proxy. It is monotonically increasing within a session and
	// is shared with any injected HTTP header so both carry the same value.
	SequenceNumber int32
}

Request represents information about an HTTP request for auditing

type SequenceCounter added in v0.10.0

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

SequenceCounter is a monotonically increasing counter that assigns a unique sequence number to every audit event within a single boundary session. The counter starts at 0 and is safe for concurrent use by both the socket auditor and the proxy.

func (*SequenceCounter) Next added in v0.10.0

func (c *SequenceCounter) Next() int32

Next returns the next sequence number. The first call returns 0, subsequent calls return 1, 2, 3, etc. It is safe for concurrent use.

type SocketAuditor

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

SocketAuditor implements the Auditor interface. It sends logs to the workspace agent's boundary log proxy socket. It queues logs and sends them in batches using a batch size and timer. The internal queue operates as a FIFO i.e., logs are sent in the order they are received and dropped if the queue is full.

func NewSocketAuditor

func NewSocketAuditor(logger *slog.Logger, socketPath string, sessionID uuid.UUID, confinedProcessName string) *SocketAuditor

NewSocketAuditor creates a new SocketAuditor that sends logs to the agent's boundary log proxy socket at socketPath after SocketAuditor.Loop is called.

func (*SocketAuditor) AuditRequest

func (s *SocketAuditor) AuditRequest(req Request)

AuditRequest implements the Auditor interface. It queues the log to be sent to the agent in a batch.

func (*SocketAuditor) Loop

func (s *SocketAuditor) Loop(ctx context.Context)

Loop handles the I/O to send audit logs to the agent.

Jump to

Keyboard shortcuts

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