config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 7 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

Index

Constants

View Source
const CurrentSchemaVersion = 2

CurrentSchemaVersion is bumped whenever we ship a breaking defaults change that should be forced onto existing user configs. Loader checks this after unmarshal and resets the relevant sections to the new defaults.

1 — original layout
2 — turn off hung/orphan/port/network detectors by default; only real
    dangers (runaway CPU, memory leak, giant spawn storms) fire by default

Variables

This section is empty.

Functions

func DefaultTelegramNotificationTypes added in v0.2.0

func DefaultTelegramNotificationTypes() []string

func ParseSize

func ParseSize(s string) uint64

ParseSize parses a human-readable size such as "10MB", "2GB", "512KB", or "10MB/min". Returns the value in bytes (or bytes per minute when /min suffix is used).

func Save

func Save(path string, cfg *Config) error

Save writes the config as YAML to the given path.

Types

type AIAutoActionConfig

type AIAutoActionConfig struct {
	Enabled             bool          `yaml:"enabled"`
	DryRun              bool          `yaml:"dry_run"`
	AllowedActions      []string      `yaml:"allowed_actions"`
	RequireRepeatCycles int           `yaml:"require_repeat_cycles"`
	CooldownPerPID      time.Duration `yaml:"cooldown_per_pid"`
}

type AIConfig

type AIConfig struct {
	Enabled                bool               `yaml:"enabled"`
	Provider               string             `yaml:"provider"`
	APIKey                 string             `yaml:"api_key"`
	Model                  string             `yaml:"model"`
	Endpoint               string             `yaml:"endpoint"`
	ExtraHeaders           map[string]string  `yaml:"extra_headers"`
	AutoAnalyzeOnCritical  bool               `yaml:"auto_analyze_on_critical"`
	MaxTokens              int                `yaml:"max_tokens"`
	MaxRequestsPerMinute   int                `yaml:"max_requests_per_minute"`
	Language               string             `yaml:"language"`
	IncludeProcessTree     bool               `yaml:"include_process_tree"`
	IncludePortMap         bool               `yaml:"include_port_map"`
	HistoryContextDuration time.Duration      `yaml:"history_context_duration"`
	Scheduler              AISchedulerConfig  `yaml:"scheduler"`
	AutoAction             AIAutoActionConfig `yaml:"auto_action"`
}

type AISchedulerConfig

type AISchedulerConfig struct {
	Enabled                 bool          `yaml:"enabled"`
	MinInterval             time.Duration `yaml:"min_interval"`
	MaxCyclesPerHour        int           `yaml:"max_cycles_per_hour"`
	MaxReservedTokensPerDay int           `yaml:"max_reserved_tokens_per_day"`
	CooldownAfterError      time.Duration `yaml:"cooldown_after_error"`
	HistoryLimit            int           `yaml:"history_limit"`
}

type AnomalyConfig

type AnomalyConfig struct {
	AnalysisInterval time.Duration        `yaml:"analysis_interval"`
	IgnoreProcesses  []string             `yaml:"ignore_processes"`
	MaxActiveAlerts  int                  `yaml:"max_active_alerts"`
	SpawnStorm       SpawnStormConfig     `yaml:"spawn_storm"`
	MemoryLeak       MemoryLeakConfig     `yaml:"memory_leak"`
	HungProcess      HungProcessConfig    `yaml:"hung_process"`
	Orphan           OrphanConfig         `yaml:"orphan"`
	RunawayCPU       RunawayCPUConfig     `yaml:"runaway_cpu"`
	PortConflict     PortConflictConfig   `yaml:"port_conflict"`
	NetworkAnomaly   NetworkAnomalyConfig `yaml:"network_anomaly"`
	NewProcess       NewProcessConfig     `yaml:"new_process"`
}

type Config

type Config struct {
	SchemaVersion  int                 `yaml:"schema_version"`
	Server         ServerConfig        `yaml:"server"`
	Monitoring     MonitoringConfig    `yaml:"monitoring"`
	Controller     ControllerConfig    `yaml:"controller"`
	Anomaly        AnomalyConfig       `yaml:"anomaly"`
	Notifications  NotificationsConfig `yaml:"notifications"`
	WellKnownPorts map[uint16]string   `yaml:"well_known_ports"`
	AI             AIConfig            `yaml:"ai"`
	Telegram       TelegramConfig      `yaml:"telegram"`
	UI             UIConfig            `yaml:"ui"`
	Rules          []Rule              `yaml:"rules"`
}

Config is the root configuration tree.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns sensible defaults for all settings.

func Load

func Load(path string) (*Config, error)

Load reads and parses a YAML config file. If the file does not exist, a default config is created.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for obvious errors.

type ControllerConfig

type ControllerConfig struct {
	ProtectedProcesses []string `yaml:"protected_processes"`
	ConfirmKillSystem  bool     `yaml:"confirm_kill_system"`
}

type HungProcessConfig

type HungProcessConfig struct {
	Enabled               bool          `yaml:"enabled"`
	ZeroActivityThreshold time.Duration `yaml:"zero_activity_threshold"`
	CriticalHungThreshold time.Duration `yaml:"critical_hung_threshold"`
	IdleWhitelist         []string      `yaml:"idle_whitelist"`
	Action                string        `yaml:"action"`
}

type MemoryLeakConfig

type MemoryLeakConfig struct {
	Enabled         bool          `yaml:"enabled"`
	Window          time.Duration `yaml:"window"`
	MinGrowthRate   string        `yaml:"min_growth_rate"`
	MinRSquared     float64       `yaml:"min_r_squared"`
	MemoryThreshold string        `yaml:"memory_threshold"`
	Action          string        `yaml:"action"`
}

type MonitoringConfig

type MonitoringConfig struct {
	Interval            time.Duration `yaml:"interval"`
	ProcessTreeInterval time.Duration `yaml:"process_tree_interval"`
	PortScanInterval    time.Duration `yaml:"port_scan_interval"`
	GPUInterval         time.Duration `yaml:"gpu_interval"`
	HistoryDuration     time.Duration `yaml:"history_duration"`
	MaxProcesses        int           `yaml:"max_processes"`
}

type NetworkAnomalyConfig

type NetworkAnomalyConfig struct {
	Enabled              bool   `yaml:"enabled"`
	ConnectionSigma      int    `yaml:"connection_sigma"`
	MaxSystemConnections int    `yaml:"max_system_connections"`
	Action               string `yaml:"action"`
}

type NewProcessConfig

type NewProcessConfig struct {
	Enabled         bool     `yaml:"enabled"`
	SuspiciousPaths []string `yaml:"suspicious_paths"`
	Action          string   `yaml:"action"`
}

type NotificationsConfig

type NotificationsConfig struct {
	TrayBalloon        bool          `yaml:"tray_balloon"`
	BalloonRateLimit   time.Duration `yaml:"balloon_rate_limit"`
	BalloonMinSeverity string        `yaml:"balloon_min_severity"`
}

type OrphanConfig

type OrphanConfig struct {
	Enabled                 bool   `yaml:"enabled"`
	ResourceThresholdCPU    int    `yaml:"resource_threshold_cpu"`
	ResourceThresholdMemory string `yaml:"resource_threshold_memory"`
	Action                  string `yaml:"action"`
}

type PortConflictConfig

type PortConflictConfig struct {
	Enabled            bool          `yaml:"enabled"`
	TimeWaitThreshold  time.Duration `yaml:"time_wait_threshold"`
	CloseWaitThreshold time.Duration `yaml:"close_wait_threshold"`
	Action             string        `yaml:"action"`
}

type Rule

type Rule struct {
	Name      string        `yaml:"name" json:"name"`
	Enabled   bool          `yaml:"enabled" json:"enabled"`
	Match     string        `yaml:"match" json:"match"`         // case-insensitive substring of process name
	Metric    string        `yaml:"metric" json:"metric"`       // "cpu_percent" | "memory_bytes" | "thread_count"
	Op        string        `yaml:"op" json:"op"`               // ">" | ">=" | "<" | "<=" (default ">=")
	Threshold float64       `yaml:"threshold" json:"threshold"` // bytes for memory, percent for cpu, count for threads
	For       time.Duration `yaml:"for" json:"for"`             // min duration condition must hold (0 = immediate)
	Action    string        `yaml:"action" json:"action"`       // "kill" | "suspend" | "alert"
	Cooldown  time.Duration `yaml:"cooldown" json:"cooldown"`   // min gap between repeat actions on same pid (default 1m)
}

Rule is a single user-defined automation rule. It says "when a process matching `match` satisfies `when` for at least `for` seconds, do `action`". Rules are evaluated on every anomaly tick and hot-reload with the config.

type RunawayCPUConfig

type RunawayCPUConfig struct {
	Enabled           bool          `yaml:"enabled"`
	CPUThreshold      int           `yaml:"cpu_threshold"`
	DurationThreshold time.Duration `yaml:"duration_threshold"`
	CriticalDuration  time.Duration `yaml:"critical_duration"`
	HighCPUWhitelist  []string      `yaml:"high_cpu_whitelist"`
	Action            string        `yaml:"action"`
}

type ServerConfig

type ServerConfig struct {
	Host        string `yaml:"host"`
	Port        int    `yaml:"port"`
	OpenBrowser bool   `yaml:"open_browser"`
}

type SpawnStormConfig

type SpawnStormConfig struct {
	Enabled              bool   `yaml:"enabled"`
	MaxChildrenPerMinute int    `yaml:"max_children_per_minute"`
	MaxTotalChildren     int    `yaml:"max_total_children"`
	Action               string `yaml:"action"`
}

type TelegramConfig

type TelegramConfig struct {
	Enabled           bool          `yaml:"enabled"`
	BotToken          string        `yaml:"bot_token"`
	AllowedChatIDs    []int64       `yaml:"allowed_chat_ids"`
	APIBaseURL        string        `yaml:"api_base_url"`
	PollTimeout       time.Duration `yaml:"poll_timeout"`
	NotifyOnCritical  bool          `yaml:"notify_on_critical"`
	NotificationMode  string        `yaml:"notification_mode"`
	NotificationTypes []string      `yaml:"notification_types"`
	RequireConfirm    bool          `yaml:"require_confirm"`
	ConfirmTTL        time.Duration `yaml:"confirm_ttl"`
}

type UIConfig

type UIConfig struct {
	Theme                string        `yaml:"theme"`
	DefaultSort          string        `yaml:"default_sort"`
	DefaultSortOrder     string        `yaml:"default_sort_order"`
	SparklinePoints      int           `yaml:"sparkline_points"`
	ProcessTablePageSize int           `yaml:"process_table_page_size"`
	RefreshRate          time.Duration `yaml:"refresh_rate"`
}

Jump to

Keyboard shortcuts

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