88 lines
2.9 KiB
Go
88 lines
2.9 KiB
Go
package config
|
|
|
|
import "time"
|
|
|
|
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 {
|
|
Enabled bool `json:"enable"`
|
|
Interval time.Duration `json:"collect_interval"`
|
|
LogFilePath string `yaml:"log_file_path"`
|
|
MaxLogSize int64 `yaml:"max_log_size"`
|
|
ProcessLimit int `json:"process_limit"`
|
|
CollectNetwork bool `json:"collect_network"`
|
|
CollectProcess bool `json:"collect_process"`
|
|
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{
|
|
Enabled: true,
|
|
Interval: 30 * time.Second,
|
|
LogFilePath: "/var/log/sysmonitord/info_monitor.log",
|
|
MaxLogSize: 10 * 1024 * 1024, // 10 MB
|
|
CollectNetwork: true,
|
|
CollectProcess: true,
|
|
ProcessLimit: 10,
|
|
ScanCPUThreshold: 80, // 默认 80% CPU 避让阈值
|
|
},
|
|
},
|
|
}
|
|
}
|