config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config handles loading and validation of the main configuration file.

Index

Constants

View Source
const (
	ThrottleBackpressure = "backpressure"
	ThrottleDiscard      = "discard"
)
View Source
const DefaultShutdownTimeout = 10 * time.Second

Variables

This section is empty.

Functions

func IsNetworkOutput

func IsNetworkOutput(t OutputType) bool

Types

type BufferMode

type BufferMode string
const (
	BufferBlock BufferMode = "block"
	BufferDrop  BufferMode = "drop"
)

type ClientTLSConfig

type ClientTLSConfig struct {
	Enabled    bool   `yaml:"enabled" json:"enabled,omitempty"`
	SkipVerify bool   `yaml:"skip_verify" json:"skip_verify,omitempty"`
	CertFile   string `yaml:"cert_file" json:"cert_file,omitempty"`
	KeyFile    string `yaml:"key_file" json:"key_file,omitempty"`
	CAFile     string `yaml:"ca_file" json:"ca_file,omitempty"`
}

type ConcurrencyConfig

type ConcurrencyConfig struct {
	ParseWorkers    *int `yaml:"parse_workers" json:"parse_workers,omitempty"`
	MatchWorkers    *int `yaml:"match_workers" json:"match_workers,omitempty"`
	ExtMatchWorkers *int `yaml:"extended_match_workers" json:"extended_match_workers,omitempty"`
	// CompositeWorkers shards composite evaluation by rule and group key.
	CompositeWorkers *int `yaml:"composite_workers" json:"composite_workers,omitempty"`
}

type Config

type Config struct {
	Input           InputConfig       `yaml:"input" json:"input"`
	Outputs         []OutputConfig    `yaml:"outputs" json:"outputs" validate:"required"`
	Rules           RulesConfig       `yaml:"rules" json:"rules"`
	Functions       FunctionsConfig   `yaml:"functions" json:"functions,omitzero"`
	Scopes          ScopesConfig      `yaml:"scopes" json:"scopes,omitzero"`
	Logging         LoggingConfig     `yaml:"logging" json:"logging"`
	Metrics         MetricsConfig     `yaml:"metrics" json:"metrics,omitzero"`
	Concurrency     ConcurrencyConfig `yaml:"concurrency" json:"concurrency,omitzero"`
	State           StateConfig       `yaml:"state" json:"state,omitzero"`
	GeoIP           GeoIPConfig       `yaml:"geoip" json:"geoip,omitzero"`
	Risk            *RiskConfig       `yaml:"risk" json:"risk,omitempty"`
	ShutdownTimeout time.Duration     `yaml:"shutdown_timeout" json:"shutdown_timeout,omitempty" validate:"gte=0"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

func NewTestConfig

func NewTestConfig(geoDB string, logBuf *bytes.Buffer) Config

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

type EventType

type EventType string
const (
	EventTypeAlerts     EventType = "alerts"
	EventTypeRiskEvents EventType = "risk_events"
)

type FileInputConfig

type FileInputConfig struct {
	Path          string `yaml:"path" json:"path" validate:"required"`
	MaxLineLength int    `yaml:"max_line_length" json:"max_line_length,omitempty"`
}

type FileOutputConfig

type FileOutputConfig struct {
	Path      string `yaml:"path" json:"path" validate:"required"`
	MaxSizeMB int    `yaml:"max_size" json:"max_size,omitempty"`
	MaxFiles  int    `yaml:"max_files" json:"max_files,omitempty"`
	Compress  bool   `yaml:"compress" json:"compress,omitempty"`
}

type FunctionsConfig

type FunctionsConfig struct {
	Directory string `yaml:"directory" json:"directory,omitempty"`
}

type GeoIPConfig

type GeoIPConfig struct {
	Path string `yaml:"path" json:"path,omitempty"`
}

type HTTPOutputConfig

type HTTPOutputConfig struct {
	URI     string            `yaml:"uri" json:"uri" validate:"required"`
	Method  string            `yaml:"method" json:"method,omitempty"`
	Headers map[string]string `yaml:"headers" json:"-"`
	Timeout time.Duration     `yaml:"timeout" json:"timeout,omitempty"`
	TLS     *ClientTLSConfig  `yaml:"tls" json:"tls,omitempty"`
}

func (HTTPOutputConfig) MarshalJSON

func (h HTTPOutputConfig) MarshalJSON() ([]byte, error)

type InputBase

type InputBase struct {
	Type          InputType      `yaml:"type"`
	Throttle      ThrottleConfig `yaml:"throttle"`
	StartPosition StartPosition  `yaml:"start_position"`
}

type InputConfig

type InputConfig struct {
	Type          InputType          `yaml:"type" json:"type" validate:"required,oneof=file kafka socket"`
	Throttle      ThrottleConfig     `json:"throttle,omitzero"`
	StartPosition StartPosition      `json:"start_position,omitempty" validate:"omitempty,oneof=resume beginning end"`
	File          *FileInputConfig   `json:"file,omitempty"`
	Kafka         *KafkaInputConfig  `json:"kafka,omitempty"`
	Socket        *SocketInputConfig `json:"socket,omitempty"`
}

func (*InputConfig) UnmarshalYAML

func (i *InputConfig) UnmarshalYAML(data []byte) error

type InputType

type InputType string
const (
	InputFile   InputType = "file"
	InputKafka  InputType = "kafka"
	InputSocket InputType = "socket"
	InputTest   InputType = "test"
)

type KafkaAuthConfig

type KafkaAuthConfig struct {
	SASL *KafkaSASLConfig `yaml:"sasl" json:"sasl,omitempty"`
}

type KafkaInputConfig

type KafkaInputConfig struct {
	Brokers         []string            `yaml:"brokers" json:"brokers" validate:"required"`
	Topic           string              `yaml:"topic" json:"topic" validate:"required"`
	ConsumerGroup   string              `yaml:"consumer_group" json:"consumer_group" validate:"required"`
	TLS             *ClientTLSConfig    `yaml:"tls" json:"tls,omitempty"`
	Auth            *KafkaAuthConfig    `yaml:"auth" json:"auth,omitempty"`
	RawKafkaVersion string              `yaml:"kafka_version" json:"kafka_version" validate:"required"`
	KafkaVersion    sarama.KafkaVersion `yaml:"-" json:"-"`
}

type KafkaOutputConfig

type KafkaOutputConfig struct {
	Brokers         []string            `yaml:"brokers" json:"brokers" validate:"required"`
	Topic           string              `yaml:"topic" json:"topic" validate:"required"`
	TLS             *ClientTLSConfig    `yaml:"tls" json:"tls,omitempty"`
	Auth            *KafkaAuthConfig    `yaml:"auth" json:"auth,omitempty"`
	RawKafkaVersion string              `yaml:"kafka_version" json:"kafka_version" validate:"required"`
	KafkaVersion    sarama.KafkaVersion `yaml:"-" json:"-"`
}

type KafkaSASLConfig

type KafkaSASLConfig struct {
	Mechanism SASLMechanism `yaml:"mechanism" json:"mechanism" validate:"required,oneof=PLAIN SCRAM-SHA-256 SCRAM-SHA-512"`
	Username  string        `yaml:"username" json:"username" validate:"required"`
	Password  string        `yaml:"password" json:"-" validate:"required"`
}

type LoggingConfig

type LoggingConfig struct {
	Type   LoggingType  `yaml:"type" json:"type" validate:"omitempty,oneof=file stdout"`
	Level  LoggingLevel `yaml:"level" json:"level" validate:"omitempty,oneof=debug info warn error"`
	Path   string       `yaml:"path" json:"path,omitempty" validate:"required_if=Type file"`
	Writer io.Writer    `yaml:"-" json:"-"`
}

type LoggingLevel

type LoggingLevel string
const (
	LoggingDebug    LoggingLevel = "debug"
	LoggingInfo     LoggingLevel = "info"
	LoggingWarn     LoggingLevel = "warn"
	LoggingError    LoggingLevel = "error"
	LoggingDisabled LoggingLevel = "disabled"
)

type LoggingType

type LoggingType string
const (
	LoggingFile   LoggingType = "file"
	LoggingStdout LoggingType = "stdout"
)

type MetricsConfig

type MetricsConfig struct {
	Port int `yaml:"port" json:"port,omitempty"`
}

type OutputBase

type OutputBase struct {
	Type                OutputType  `yaml:"type"`
	Indent              bool        `yaml:"indent"`
	Events              []EventType `yaml:"events"`
	BufferSize          *int        `yaml:"buffer_size,omitempty"`
	BufferMode          BufferMode  `yaml:"buffer_mode,omitempty"`
	AllowStartupFailure bool        `yaml:"allow_startup_failure,omitempty"`
}

type OutputConfig

type OutputConfig struct {
	Type                OutputType          `json:"type"`
	Indent              bool                `json:"indent,omitempty"`
	Events              []EventType         `json:"events,omitempty"`
	BufferSize          *int                `json:"buffer_size,omitempty"`
	BufferMode          BufferMode          `json:"buffer_mode,omitempty"`
	AllowStartupFailure bool                `json:"allow_startup_failure,omitempty"`
	Kafka               *KafkaOutputConfig  `json:"kafka,omitempty"`
	File                *FileOutputConfig   `json:"file,omitempty"`
	HTTP                *HTTPOutputConfig   `json:"http,omitempty"`
	Socket              *SocketOutputConfig `json:"socket,omitempty"`
}

func (*OutputConfig) Accepts

func (o *OutputConfig) Accepts(et EventType) bool

func (*OutputConfig) EffectiveBufferMode

func (o *OutputConfig) EffectiveBufferMode() BufferMode

func (*OutputConfig) EffectiveBufferSize

func (o *OutputConfig) EffectiveBufferSize() int

func (*OutputConfig) UnmarshalYAML

func (o *OutputConfig) UnmarshalYAML(data []byte) error

type OutputType

type OutputType string
const (
	OutputStdout OutputType = "stdout"
	OutputKafka  OutputType = "kafka"
	OutputFile   OutputType = "file"
	OutputHTTP   OutputType = "http"
	OutputSocket OutputType = "socket"
	OutputTest   OutputType = "test"
)

type RiskConfig

type RiskConfig struct {
	Alerts     *bool                     `yaml:"alerts" json:"alerts,omitempty"`
	Thresholds map[string]RiskThresholds `yaml:"thresholds" json:"thresholds,omitempty"`
	Defaults   RiskDefaults              `yaml:"defaults" json:"defaults,omitzero"`
}

func (*RiskConfig) AlertsEnabled

func (r *RiskConfig) AlertsEnabled() bool

func (*RiskConfig) Enabled

func (r *RiskConfig) Enabled() bool

type RiskDecayType

type RiskDecayType string
const (
	RiskDecayNone   RiskDecayType = "none"
	RiskDecayLinear RiskDecayType = "linear"
)

type RiskDefaults

type RiskDefaults struct {
	TTL   time.Duration `yaml:"ttl" json:"ttl,omitempty"`
	Decay RiskDecayType `yaml:"decay" json:"decay,omitempty" validate:"omitempty,oneof=none linear"`
}

func (RiskDefaults) MarshalJSON

func (r RiskDefaults) MarshalJSON() ([]byte, error)

type RiskThresholds

type RiskThresholds struct {
	Low        float64 `yaml:"low" json:"low,omitempty"`
	Medium     float64 `yaml:"medium" json:"medium,omitempty"`
	High       float64 `yaml:"high" json:"high,omitempty"`
	Critical   float64 `yaml:"critical" json:"critical,omitempty"`
	AlertLevel string  `yaml:"alert_level" json:"alert_level,omitempty" validate:"omitempty,oneof=low medium high critical"`
}

type RulesConfig

type RulesConfig struct {
	Directory string `yaml:"directory" json:"directory,omitempty" validate:"required"`
}

type SASLMechanism

type SASLMechanism string
const (
	SASLPlain       SASLMechanism = "PLAIN"
	SASLSCRAMSHA256 SASLMechanism = "SCRAM-SHA-256"
	SASLSCRAMSHA512 SASLMechanism = "SCRAM-SHA-512"
)

type ScopesConfig

type ScopesConfig struct {
	Directory string `yaml:"directory" json:"directory,omitempty"`
}

type SocketInputConfig

type SocketInputConfig struct {
	Mode           string     `yaml:"mode" json:"mode" validate:"required,oneof=tcp unix"`
	Address        string     `yaml:"address" json:"address,omitempty" validate:"required_if=Mode tcp"`
	Path           string     `yaml:"path" json:"path,omitempty" validate:"required_if=Mode unix"`
	MaxConnections int        `yaml:"max_connections" json:"max_connections,omitempty"`
	MaxLineLength  int        `yaml:"max_line_length" json:"max_line_length,omitempty"`
	TLS            *TLSConfig `yaml:"tls" json:"tls,omitempty"`
}

type SocketOutputConfig

type SocketOutputConfig struct {
	Mode    string           `yaml:"mode" json:"mode" validate:"required,oneof=tcp unix"`
	Address string           `yaml:"address" json:"address,omitempty" validate:"required_if=Mode tcp"`
	Path    string           `yaml:"path" json:"path,omitempty" validate:"required_if=Mode unix"`
	TLS     *ClientTLSConfig `yaml:"tls" json:"tls,omitempty"`
}

type StartPosition

type StartPosition string
const (
	StartResume    StartPosition = "resume"
	StartBeginning StartPosition = "beginning"
	StartEnd       StartPosition = "end"
)

type StateConfig

type StateConfig struct {
	Directory string `yaml:"directory" json:"directory,omitempty"`
	// FlushInterval bounds how much state a crash can lose (default 1s).
	FlushInterval time.Duration `yaml:"flush_interval" json:"flush_interval,omitempty" validate:"gte=0"`
	InMemory      bool          `yaml:"-" json:"-"`
}

func (StateConfig) IsZero

func (s StateConfig) IsZero() bool

func (StateConfig) MarshalJSON

func (s StateConfig) MarshalJSON() ([]byte, error)

type TLSConfig

type TLSConfig struct {
	CertFile string `yaml:"cert_file" json:"cert_file" validate:"required"`
	KeyFile  string `yaml:"key_file" json:"key_file" validate:"required"`
	CAFile   string `yaml:"ca_file" json:"ca_file,omitempty"`
}

type ThrottleConfig

type ThrottleConfig struct {
	Enabled    bool          `yaml:"enabled" json:"enabled"`
	Mode       ThrottleMode  `yaml:"mode" json:"mode,omitempty" validate:"required_if=Enabled true,omitempty,oneof=backpressure discard"`
	MaxEvents  int           `yaml:"max_events" json:"max_events,omitempty" validate:"required_if=Enabled true"`
	Period     time.Duration `yaml:"period" json:"period,omitempty" validate:"required_if=Enabled true"`
	BufferSize int           `yaml:"buffer_size" json:"buffer_size,omitempty" validate:"required_if=Enabled true"`
}

func (ThrottleConfig) MarshalJSON

func (t ThrottleConfig) MarshalJSON() ([]byte, error)

type ThrottleMode

type ThrottleMode string

Jump to

Keyboard shortcuts

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