backends

package
v0.0.0-...-c0d7cef Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package backends provides storage backend implementations for audit log data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureBackend

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

AzureBackend implements the Backend interface for Azure Blob Storage

func NewAzureBackend

func NewAzureBackend(cfg AzureConfig) (*AzureBackend, error)

NewAzureBackend creates a new Azure backend

func (*AzureBackend) Close

func (ab *AzureBackend) Close() error

Close closes the Azure backend

func (*AzureBackend) Name

func (ab *AzureBackend) Name() string

Name returns the backend name

func (*AzureBackend) Read

func (ab *AzureBackend) Read(_, _ time.Time) ([]*core.LogEvent, error)

Read reads events from Azure (not implemented for audit logs)

func (*AzureBackend) VerifyIntegrity

func (ab *AzureBackend) VerifyIntegrity() (*IntegrityReport, error)

VerifyIntegrity verifies the integrity of stored data

func (*AzureBackend) Write

func (ab *AzureBackend) Write(event *core.LogEvent) error

Write writes an event to Azure

func (*AzureBackend) WriteBatch

func (ab *AzureBackend) WriteBatch(events []*core.LogEvent) error

WriteBatch writes multiple events to Azure

type AzureConfig

type AzureConfig struct {
	Container        string `json:"container"`
	ConnectionString string `json:"connection_string"`
	Prefix           string `json:"prefix"`
	AccessTier       string `json:"access_tier"`
	Immutable        bool   `json:"immutable"`
	RetentionDays    int    `json:"retention_days"`
}

AzureConfig configures an Azure Blob Storage backend

func (AzureConfig) Type

func (c AzureConfig) Type() string

Type returns the backend type identifier.

func (AzureConfig) Validate

func (c AzureConfig) Validate() error

Validate validates the Azure configuration.

type Backend

type Backend interface {
	// Write writes an event to the backend
	Write(event *core.LogEvent) error

	// WriteBatch writes multiple events efficiently
	WriteBatch(events []*core.LogEvent) error

	// Read reads events within a time range
	Read(start, end time.Time) ([]*core.LogEvent, error)

	// VerifyIntegrity verifies the integrity of stored data
	VerifyIntegrity() (*IntegrityReport, error)

	// Name returns the backend name
	Name() string

	// Close closes the backend
	Close() error
}

Backend defines the interface for storage backends

func Create

func Create(config Config) (Backend, error)

Create creates a backend from configuration

type BackendError

type BackendError struct {
	Err     error
	Backend string
	Op      string
}

BackendError represents a backend-specific error

func (*BackendError) Error

func (e *BackendError) Error() string

func (*BackendError) Unwrap

func (e *BackendError) Unwrap() error

type Config

type Config interface {
	Type() string
	Validate() error
}

Config defines backend configuration

type FilesystemBackend

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

FilesystemBackend implements filesystem-based storage with redundancy

func NewFilesystemBackend

func NewFilesystemBackend(config FilesystemConfig) (*FilesystemBackend, error)

NewFilesystemBackend creates a new filesystem backend

func (*FilesystemBackend) Close

func (fb *FilesystemBackend) Close() error

Close closes the backend

func (*FilesystemBackend) Name

func (fb *FilesystemBackend) Name() string

Name returns the backend name

func (*FilesystemBackend) Read

func (fb *FilesystemBackend) Read(start, end time.Time) ([]*core.LogEvent, error)

Read reads events within a time range

func (*FilesystemBackend) VerifyIntegrity

func (fb *FilesystemBackend) VerifyIntegrity() (*IntegrityReport, error)

VerifyIntegrity verifies the integrity of stored data

func (*FilesystemBackend) Write

func (fb *FilesystemBackend) Write(event *core.LogEvent) error

Write writes an event to the filesystem

func (*FilesystemBackend) WriteBatch

func (fb *FilesystemBackend) WriteBatch(events []*core.LogEvent) error

WriteBatch writes multiple events efficiently

type FilesystemConfig

type FilesystemConfig struct {
	Path     string        `json:"path"`
	SyncMode SyncMode      `json:"sync_mode"`
	MaxSize  int64         `json:"max_size"` // Max file size before rotation
	MaxAge   time.Duration `json:"max_age"`  // Max age before rotation
	Compress bool          `json:"compress"` // Compress rotated files
	Shadow   bool          `json:"shadow"`   // Shadow copy for redundancy
}

FilesystemConfig configures a filesystem backend

func (FilesystemConfig) Type

func (c FilesystemConfig) Type() string

Type returns the backend type identifier.

func (FilesystemConfig) Validate

func (c FilesystemConfig) Validate() error

Validate validates the filesystem configuration.

type GCSBackend

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

GCSBackend implements the Backend interface for Google Cloud Storage

func NewGCSBackend

func NewGCSBackend(cfg GCSConfig) (*GCSBackend, error)

NewGCSBackend creates a new GCS backend

func (*GCSBackend) Close

func (gb *GCSBackend) Close() error

Close closes the GCS backend

func (*GCSBackend) Name

func (gb *GCSBackend) Name() string

Name returns the backend name

func (*GCSBackend) Read

func (gb *GCSBackend) Read(_, _ time.Time) ([]*core.LogEvent, error)

Read reads events from GCS (not implemented for audit logs)

func (*GCSBackend) VerifyIntegrity

func (gb *GCSBackend) VerifyIntegrity() (*IntegrityReport, error)

VerifyIntegrity verifies the integrity of stored data

func (*GCSBackend) Write

func (gb *GCSBackend) Write(event *core.LogEvent) error

Write writes an event to GCS

func (*GCSBackend) WriteBatch

func (gb *GCSBackend) WriteBatch(events []*core.LogEvent) error

WriteBatch writes multiple events to GCS

type GCSConfig

type GCSConfig struct {
	Bucket          string `json:"bucket"`
	ProjectID       string `json:"project_id"`
	Prefix          string `json:"prefix"`
	StorageClass    string `json:"storage_class"`
	Region          string `json:"region"`
	CredentialsFile string `json:"credentials_file"`
	RetentionDays   int    `json:"retention_days"`
	Versioning      bool   `json:"versioning"`
}

GCSConfig configures a Google Cloud Storage backend

func (GCSConfig) Type

func (c GCSConfig) Type() string

Type returns the backend type identifier.

func (GCSConfig) Validate

func (c GCSConfig) Validate() error

Validate validates the GCS configuration.

type IntegrityReport

type IntegrityReport struct {
	Timestamp        time.Time `json:"timestamp"`
	Backend          string    `json:"backend"`
	Errors           []string  `json:"errors,omitempty"`
	TotalRecords     int64     `json:"total_records"`
	VerifiedRecords  int64     `json:"verified_records"`
	CorruptedRecords int64     `json:"corrupted_records"`
	Valid            bool      `json:"valid"`
}

IntegrityReport contains integrity verification results

type Query

type Query struct {
	StartTime time.Time
	EndTime   time.Time
	Filters   map[string]interface{}
	Limit     int
}

Query represents a query for reading events

type S3Backend

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

S3Backend implements AWS S3 storage backend with compliance features

func NewS3Backend

func NewS3Backend(cfg S3Config, opts ...S3Option) (*S3Backend, error)

NewS3Backend creates a new S3 backend

func (*S3Backend) Close

func (s *S3Backend) Close() error

Close closes the backend

func (*S3Backend) GetStats

func (s *S3Backend) GetStats() S3Stats

GetStats returns backend statistics

func (*S3Backend) Name

func (s *S3Backend) Name() string

Name returns the backend name

func (*S3Backend) Read

func (s *S3Backend) Read(start, end time.Time) ([]*core.LogEvent, error)

Read reads events within a time range

func (*S3Backend) VerifyIntegrity

func (s *S3Backend) VerifyIntegrity() (*IntegrityReport, error)

VerifyIntegrity verifies the integrity of S3 data

func (*S3Backend) Write

func (s *S3Backend) Write(event *core.LogEvent) error

Write writes an event to S3

func (*S3Backend) WriteBatch

func (s *S3Backend) WriteBatch(events []*core.LogEvent) error

WriteBatch writes multiple events efficiently

type S3Config

type S3Config struct {
	Bucket               string `json:"bucket"`
	Region               string `json:"region"`
	Prefix               string `json:"prefix"`
	StorageClass         string `json:"storage_class"`
	ServerSideEncryption bool   `json:"server_side_encryption"`
	Versioning           bool   `json:"versioning"`
	ObjectLock           bool   `json:"object_lock"`
	RetentionDays        int    `json:"retention_days"`
}

S3Config configures an S3 backend

func (S3Config) Type

func (c S3Config) Type() string

Type returns the backend type identifier.

func (S3Config) Validate

func (c S3Config) Validate() error

Validate validates the S3 configuration.

type S3Option

type S3Option func(*S3Backend)

S3Option configures S3 backend

func WithBatchSize

func WithBatchSize(size int) S3Option

WithBatchSize sets the batch size for writes

func WithCompression

func WithCompression() S3Option

WithCompression enables gzip compression

func WithKMSKeyID

func WithKMSKeyID(keyID string) S3Option

WithKMSKeyID sets the KMS key for encryption

func WithObjectLock

func WithObjectLock(retentionDays int) S3Option

WithObjectLock enables S3 Object Lock for compliance

func WithServerSideEncryption

func WithServerSideEncryption(algorithm string) S3Option

WithServerSideEncryption enables server-side encryption

func WithStorageClass

func WithStorageClass(class string) S3Option

WithStorageClass sets the S3 storage class

func WithVersioning

func WithVersioning() S3Option

WithVersioning enables S3 versioning

type S3Stats

type S3Stats struct {
	LastWrite     time.Time
	Bucket        string
	Prefix        string
	WriteCount    int64
	ErrorCount    int64
	RetentionDays int
	ObjectLock    bool
	Versioning    bool
	Encryption    bool
}

S3Stats contains S3 backend statistics

type SyncMode

type SyncMode int

SyncMode defines synchronization modes

const (
	// SyncImmediate syncs after every write
	SyncImmediate SyncMode = iota
	// SyncInterval syncs periodically
	SyncInterval
	// SyncBatch syncs after batch
	SyncBatch
)

Jump to

Keyboard shortcuts

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