customrules

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinCustomSID = 9000000
	MaxCustomSID = 9999999
)

SID range for custom rules (9000000-9999999)

Variables

This section is empty.

Functions

func GetNextAvailableSID

func GetNextAvailableSID(rulesDir string) (int, error)

GetNextAvailableSID finds the next available SID in custom range

func SanitizeRule

func SanitizeRule(rule string) string

SanitizeRule removes extra whitespace and normalizes formatting

func ValidateSIDAvailable

func ValidateSIDAvailable(sid int, rulesDir string) (bool, error)

ValidateSIDAvailable checks if a SID is already in use

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 NewManager

func NewManager() (*Manager, error)

NewManager creates a new custom rules manager

func (*Manager) AddRule

func (m *Manager) AddRule(rule string) (*ValidationResult, error)

AddRule adds a new custom rule

func (*Manager) CreateBackup

func (m *Manager) CreateBackup() error

CreateBackup creates a timestamped backup of custom.rules

func (*Manager) DisableRule

func (m *Manager) DisableRule(sid int) error

DisableRule disables a rule by commenting it out

func (*Manager) EnableRule

func (m *Manager) EnableRule(sid int) error

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

func (m *Manager) ListBackups() ([]string, error)

ListBackups lists available backups

func (*Manager) ListRules

func (m *Manager) ListRules() ([]*CustomRule, error)

ListRules lists all custom rules

func (*Manager) RemoveRule

func (m *Manager) RemoveRule(sid int) error

RemoveRule removes a custom rule by SID

func (*Manager) Rollback

func (m *Manager) Rollback(backupName string) error

Rollback restores from a backup

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

Jump to

Keyboard shortcuts

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