state

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*bolt.DB
	// contains filtered or unexported fields
}

DB wraps BoltDB with santamon-specific operations

func Open

func Open(path string, maxFirstSeen int, syncWrites bool) (*DB, error)

Open opens or creates the BoltDB database

func (*DB) CleanWindowEvents

func (db *DB) CleanWindowEvents(ruleID, groupKey string, keepCount int) error

CleanWindowEvents removes old events from correlation windows

func (*DB) Compact

func (db *DB) Compact() error

Compact performs database compaction

func (*DB) DequeueSignals

func (db *DB) DequeueSignals(limit int) ([]*Signal, error)

DequeueSignals retrieves and removes up to limit signals from the queue

func (*DB) EnqueueSignal

func (db *DB) EnqueueSignal(sig *Signal) error

EnqueueSignal adds a signal to the outbox queue

func (*DB) EnqueueSignalIfNotShipped

func (db *DB) EnqueueSignalIfNotShipped(sig *Signal) (bool, error)

EnqueueSignalIfNotShipped atomically checks if a signal was already shipped and enqueues it only if not. Returns true if the signal was enqueued. This prevents the race condition where two goroutines could both enqueue the same signal by doing the check and enqueue in a single transaction.

func (*DB) GetJournalEntry

func (db *DB) GetJournalEntry(filename string) (*JournalEntry, error)

GetJournalEntry retrieves the processing progress for a spool file

func (*DB) GetMeta

func (db *DB) GetMeta(key string) (string, error)

GetMeta retrieves a metadata value

func (*DB) GetWindowEvents

func (db *DB) GetWindowEvents(ruleID, groupKey string) ([]map[string]any, error)

GetWindowEvents retrieves events for a correlation window

func (*DB) IsFirstSeen

func (db *DB) IsFirstSeen(kind, id string) (bool, error)

IsFirstSeen checks if an artifact is being seen for the first time Returns true if first seen, false if already tracked

func (*DB) IsShipped

func (db *DB) IsShipped(signalID string) (bool, error)

IsShipped checks if a signal has already been shipped

func (*DB) MarkShipped

func (db *DB) MarkShipped(signalID string) error

MarkShipped records that a signal was successfully shipped

func (*DB) ReplaceWindowEvents

func (db *DB) ReplaceWindowEvents(ruleID, groupKey string, events []map[string]any) error

ReplaceWindowEvents overwrites a correlation window with the provided events. If events is empty or nil, the entry is removed.

func (*DB) SetMeta

func (db *DB) SetMeta(key, value string) error

SetMeta stores a metadata key-value pair

func (*DB) Stats

func (db *DB) Stats() (map[string]any, error)

Stats returns database statistics

func (*DB) StoreWindowEvent

func (db *DB) StoreWindowEvent(ruleID, groupKey string, event map[string]any) error

StoreWindowEvent stores an event for correlation window processing

func (*DB) UpdateJournal

func (db *DB) UpdateJournal(filename string, offset int64) error

UpdateJournal records progress processing a spool file

type FirstSeenEntry

type FirstSeenEntry struct {
	First time.Time `json:"first"`
	Count int       `json:"count"`
	Last  time.Time `json:"last"`
}

FirstSeenEntry tracks when an artifact was first observed

type JournalEntry

type JournalEntry struct {
	Offset      int64     `json:"offset"`
	ProcessedTS time.Time `json:"processed_ts"`
}

JournalEntry tracks spool file processing progress

type Signal

type Signal struct {
	ID              string         `json:"signal_id"`
	TS              time.Time      `json:"ts"`
	HostID          string         `json:"host_id"`
	RuleID          string         `json:"rule_id"`
	RuleDescription string         `json:"rule_description,omitempty"`
	Status          string         `json:"status"`
	Severity        string         `json:"severity"`
	Title           string         `json:"title"`
	Tags            []string       `json:"tags"`
	Context         map[string]any `json:"context"`
}

Signal represents a detection signal

Jump to

Keyboard shortcuts

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