package config type OfficialConfig struct { Version string `json:"version"` WhitelistFiles map[string][]string `json:"whitelist_files"` WhitelistProcesses []string `json:"whitelist_processes"` IgnoredPaths []string `json:"ignored_paths"` ScanPaths []string `json:"scan_paths"` } type UserConfig struct { Version string `json:"version"` Connection ConnectionConfig `json:"connection"` Modules ModuleSwitches `json:"modules"` SupplementFiles map[string][]string `json:"supplement_files"` SupplementProcesses []string `json:"supplement_processes"` IgnoredPaths []string `json:"ignored_paths"` MonitorConfig MonitorConfig `json:"monitor_config"` } type ModuleSwitches struct { FileScanner bool `json:"file_scanner"` FileWatcher bool `json:"file_watcher"` SSHMonitor bool `json:"ssh_monitor"` SystemMonitor bool `json:"system_monitor"` } type SSHMonitorConfig struct { Enabled bool `json:"enabled"` AlertOnRootLogin bool `json:"alert_on_root_login"` } type SystemMonitorConfig struct { CollectInterval string `json:"collect_interval"` CollectNetwork bool `json:"collect_network"` CollectProcess bool `json:"collect_process"` ProcessLimit int `json:"process_limit"` ScanCPUThreshold int `json:"scan_cpu_threshold"` } type MonitorConfig struct { SSHMonitorConfig SSHMonitorConfig `json:"ssh_monitor"` SystemMonitorConfig SystemMonitorConfig `json:"system_monitor"` } type ConnectionConfig struct { CenterServerURL string `json:"center_server_url"` AuditServerURL string `json:"audit_server_url"` } type Configuration struct { Official OfficialConfig // 官方配置 User UserConfig // 用户自定义配置 } func NewDefaultUserConfig() UserConfig { return UserConfig{ Version: "BuildInDefault", Connection: ConnectionConfig{ CenterServerURL: "ws://localhost:8090/api/v1/ws", }, Modules: ModuleSwitches{ FileScanner: false, FileWatcher: true, SSHMonitor: true, SystemMonitor: true, }, MonitorConfig: MonitorConfig{ SSHMonitorConfig: SSHMonitorConfig{Enabled: true}, SystemMonitorConfig: SystemMonitorConfig{ CollectInterval: "30s", CollectNetwork: true, CollectProcess: true, ProcessLimit: 10, ScanCPUThreshold: 80, // 默认 80% CPU 避让阈值 }, }, } }