audit

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditConfig

type AuditConfig struct {
	Enabled         bool                   `yaml:"enabled" json:"enabled"`
	BufferSize      int                    `yaml:"buffer_size" json:"buffer_size"`
	FlushInterval   time.Duration          `yaml:"flush_interval" json:"flush_interval"`
	RetentionPeriod time.Duration          `yaml:"retention_period" json:"retention_period"`
	Destinations    []AuditDestination     `yaml:"destinations" json:"destinations"`
	Filters         []AuditFilter          `yaml:"filters" json:"filters"`
	Encryption      *EncryptionConfig      `yaml:"encryption" json:"encryption"`
	Compression     bool                   `yaml:"compression" json:"compression"`
	Metadata        map[string]interface{} `yaml:"metadata" json:"metadata"`
}

AuditConfig holds audit logging configuration

type AuditDestination

type AuditDestination struct {
	Type     string                 `yaml:"type" json:"type"` // file, database, syslog, webhook, s3
	Enabled  bool                   `yaml:"enabled" json:"enabled"`
	Settings map[string]interface{} `yaml:"settings" json:"settings"`
}

AuditDestination represents an audit log destination

type AuditEntry

type AuditEntry struct {
	ID            string                 `json:"id"`
	Timestamp     time.Time              `json:"timestamp"`
	EventType     string                 `json:"event_type"`
	Action        string                 `json:"action"`
	Resource      string                 `json:"resource"`
	UserID        string                 `json:"user_id"`
	UserName      string                 `json:"user_name"`
	UserRole      string                 `json:"user_role"`
	SourceIP      string                 `json:"source_ip"`
	UserAgent     string                 `json:"user_agent"`
	SessionID     string                 `json:"session_id"`
	Severity      AuditSeverity          `json:"severity"`
	Status        string                 `json:"status"`
	Message       string                 `json:"message"`
	Details       map[string]interface{} `json:"details"`
	RiskScore     float64                `json:"risk_score"`
	Tags          []string               `json:"tags"`
	CorrelationID string                 `json:"correlation_id"`
	Metadata      map[string]interface{} `json:"metadata"`
}

AuditEntry represents a single audit log entry

type AuditFilter

type AuditFilter struct {
	Name      string   `yaml:"name" json:"name"`
	EventType string   `yaml:"event_type" json:"event_type"`
	Severity  string   `yaml:"severity" json:"severity"`
	Users     []string `yaml:"users" json:"users"`
	Actions   []string `yaml:"actions" json:"actions"`
	Enabled   bool     `yaml:"enabled" json:"enabled"`
}

AuditFilter defines filtering rules for audit logs

type AuditLogger

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

AuditLogger provides enterprise audit logging capabilities

func NewAuditLogger

func NewAuditLogger(config *AuditConfig, logger logger.Logger) (*AuditLogger, error)

NewAuditLogger creates a new audit logger

func (*AuditLogger) GetAuditEntries

func (al *AuditLogger) GetAuditEntries(ctx context.Context, criteria *AuditSearchCriteria) ([]*AuditEntry, error)

GetAuditEntries retrieves audit entries based on criteria

func (*AuditLogger) LogComplianceEvent

func (al *AuditLogger) LogComplianceEvent(ctx context.Context, action, resource, regulation string, compliant bool, details map[string]interface{})

LogComplianceEvent logs a compliance-related audit event

func (*AuditLogger) LogEvent

func (al *AuditLogger) LogEvent(ctx context.Context, eventType, action, resource string, details map[string]interface{})

LogEvent logs an audit event

func (*AuditLogger) LogSecurityEvent

func (al *AuditLogger) LogSecurityEvent(ctx context.Context, action, resource, message string, severity AuditSeverity, details map[string]interface{})

LogSecurityEvent logs a security-related audit event

func (*AuditLogger) Start

func (al *AuditLogger) Start(ctx context.Context) error

Start starts the audit logger

func (*AuditLogger) Stop

func (al *AuditLogger) Stop() error

Stop stops the audit logger

type AuditSearchCriteria

type AuditSearchCriteria struct {
	StartTime *time.Time `json:"start_time"`
	EndTime   *time.Time `json:"end_time"`
	EventType string     `json:"event_type"`
	Action    string     `json:"action"`
	UserID    string     `json:"user_id"`
	Resource  string     `json:"resource"`
	Severity  string     `json:"severity"`
	Limit     int        `json:"limit"`
	Offset    int        `json:"offset"`
}

AuditSearchCriteria defines search criteria for audit entries

type AuditSeverity

type AuditSeverity string

AuditSeverity represents audit event severity levels

const (
	AuditSeverityInfo     AuditSeverity = "info"
	AuditSeverityWarning  AuditSeverity = "warning"
	AuditSeverityError    AuditSeverity = "error"
	AuditSeverityCritical AuditSeverity = "critical"
)

type AuditWriter

type AuditWriter interface {
	Write(entry *AuditEntry) error
	Flush() error
	Close() error
	Name() string
}

AuditWriter interface for different audit destinations

func NewDatabaseAuditWriter

func NewDatabaseAuditWriter(settings map[string]interface{}) (AuditWriter, error)

NewDatabaseAuditWriter creates a new database audit writer

func NewFileAuditWriter

func NewFileAuditWriter(settings map[string]interface{}) (AuditWriter, error)

NewFileAuditWriter creates a new file audit writer

func NewSyslogAuditWriter

func NewSyslogAuditWriter(settings map[string]interface{}) (AuditWriter, error)

NewSyslogAuditWriter creates a new syslog audit writer

func NewWebhookAuditWriter

func NewWebhookAuditWriter(settings map[string]interface{}) (AuditWriter, error)

NewWebhookAuditWriter creates a new webhook audit writer

type DatabaseAuditWriter

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

DatabaseAuditWriter writes audit logs to a database

func (*DatabaseAuditWriter) Close

func (d *DatabaseAuditWriter) Close() error

func (*DatabaseAuditWriter) Flush

func (d *DatabaseAuditWriter) Flush() error

func (*DatabaseAuditWriter) Name

func (d *DatabaseAuditWriter) Name() string

func (*DatabaseAuditWriter) Write

func (d *DatabaseAuditWriter) Write(entry *AuditEntry) error

type EncryptionConfig

type EncryptionConfig struct {
	Enabled   bool   `yaml:"enabled" json:"enabled"`
	Algorithm string `yaml:"algorithm" json:"algorithm"`
	KeyPath   string `yaml:"key_path" json:"key_path"`
}

EncryptionConfig holds encryption settings for audit logs

type FileAuditWriter

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

FileAuditWriter writes audit logs to files

func (*FileAuditWriter) Close

func (f *FileAuditWriter) Close() error

func (*FileAuditWriter) Flush

func (f *FileAuditWriter) Flush() error

func (*FileAuditWriter) Name

func (f *FileAuditWriter) Name() string

func (*FileAuditWriter) Write

func (f *FileAuditWriter) Write(entry *AuditEntry) error

type SyslogAuditWriter

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

SyslogAuditWriter writes audit logs to syslog

func (*SyslogAuditWriter) Close

func (s *SyslogAuditWriter) Close() error

func (*SyslogAuditWriter) Flush

func (s *SyslogAuditWriter) Flush() error

func (*SyslogAuditWriter) Name

func (s *SyslogAuditWriter) Name() string

func (*SyslogAuditWriter) Write

func (s *SyslogAuditWriter) Write(entry *AuditEntry) error

type WebhookAuditWriter

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

WebhookAuditWriter sends audit logs to a webhook endpoint

func (*WebhookAuditWriter) Close

func (w *WebhookAuditWriter) Close() error

func (*WebhookAuditWriter) Flush

func (w *WebhookAuditWriter) Flush() error

func (*WebhookAuditWriter) Name

func (w *WebhookAuditWriter) Name() string

func (*WebhookAuditWriter) Write

func (w *WebhookAuditWriter) Write(entry *AuditEntry) error

Jump to

Keyboard shortcuts

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