Documentation
¶
Index ¶
- Constants
- func GetNextAvailableSID(rulesDir string) (int, error)
- func SanitizeRule(rule string) string
- func ValidateSIDAvailable(sid int, rulesDir string) (bool, error)
- type CustomRule
- type Manager
- func (m *Manager) AddRule(rule string) (*ValidationResult, error)
- func (m *Manager) CreateBackup() error
- func (m *Manager) DisableRule(sid int) error
- func (m *Manager) EnableRule(sid int) error
- func (m *Manager) GetRule(sid int) (*CustomRule, error)
- func (m *Manager) ListBackups() ([]string, error)
- func (m *Manager) ListRules() ([]*CustomRule, error)
- func (m *Manager) RemoveRule(sid int) error
- func (m *Manager) Rollback(backupName string) error
- func (m *Manager) UpdateRule(sid int, newRule string) (*ValidationResult, error)
- func (m *Manager) ValidateAll() (map[int]*ValidationResult, error)
- type ValidationResult
Constants ¶
const ( MinCustomSID = 9000000 MaxCustomSID = 9999999 )
SID range for custom rules (9000000-9999999)
Variables ¶
This section is empty.
Functions ¶
func GetNextAvailableSID ¶
GetNextAvailableSID finds the next available SID in custom range
func SanitizeRule ¶
SanitizeRule removes extra whitespace and normalizes formatting
Types ¶
type CustomRule ¶
type CustomRule struct {
SID int
FilePath string
Rule string
Message string
Action string
Enabled bool
}
CustomRule represents a custom Suricata rule
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles custom rule operations
func (*Manager) AddRule ¶
func (m *Manager) AddRule(rule string) (*ValidationResult, error)
AddRule adds a new custom rule
func (*Manager) CreateBackup ¶
CreateBackup creates a timestamped backup of custom.rules
func (*Manager) DisableRule ¶
DisableRule disables a rule by commenting it out
func (*Manager) EnableRule ¶
EnableRule enables a rule by removing comment
func (*Manager) GetRule ¶
func (m *Manager) GetRule(sid int) (*CustomRule, error)
GetRule retrieves a specific rule by SID
func (*Manager) ListBackups ¶
ListBackups lists available backups
func (*Manager) ListRules ¶
func (m *Manager) ListRules() ([]*CustomRule, error)
ListRules lists all custom rules
func (*Manager) RemoveRule ¶
RemoveRule removes a custom rule by SID
func (*Manager) UpdateRule ¶
func (m *Manager) UpdateRule(sid int, newRule string) (*ValidationResult, error)
UpdateRule updates an existing rule
func (*Manager) ValidateAll ¶
func (m *Manager) ValidateAll() (map[int]*ValidationResult, error)
ValidateAll validates all custom rules
type ValidationResult ¶
type ValidationResult struct {
Valid bool
Errors []string
SID int
Action string // alert, drop, reject
Message string
}
ValidationResult holds validation outcome
func ValidateRule ¶
func ValidateRule(rule string) (*ValidationResult, error)
ValidateRule validates a Suricata rule