Documentation
¶
Overview ¶
Package storage persists scans and findings. It provides an in-memory ring buffer backend for the hot path and a pure-Go SQLite backend for durability.
Index ¶
- Constants
- Variables
- type FindingFilter
- type Memory
- func (m *Memory) Close() error
- func (m *Memory) GetScan(_ context.Context, id string) (core.ScanResult, error)
- func (m *Memory) LatestScan(_ context.Context, target string) (core.ScanResult, error)
- func (m *Memory) ListFindings(_ context.Context, f FindingFilter) ([]core.Finding, error)
- func (m *Memory) ListScans(_ context.Context, limit int) ([]core.ScanResult, error)
- func (m *Memory) Prune(_ context.Context, before time.Time) (int, error)
- func (m *Memory) SaveScan(_ context.Context, s core.ScanResult) error
- type SQLite
- func (s *SQLite) Close() error
- func (s *SQLite) GetScan(ctx context.Context, id string) (core.ScanResult, error)
- func (s *SQLite) LatestScan(ctx context.Context, target string) (core.ScanResult, error)
- func (s *SQLite) ListFindings(ctx context.Context, f FindingFilter) ([]core.Finding, error)
- func (s *SQLite) ListScans(ctx context.Context, limit int) ([]core.ScanResult, error)
- func (s *SQLite) Prune(ctx context.Context, before time.Time) (int, error)
- func (s *SQLite) SaveScan(ctx context.Context, sc core.ScanResult) error
- type Store
Constants ¶
const DefaultMemoryCapacity = 100
DefaultMemoryCapacity is how many scans the memory store keeps.
Variables ¶
var ErrNotFound = errors.New("storage: not found")
ErrNotFound is returned when a scan or finding does not exist.
Functions ¶
This section is empty.
Types ¶
type FindingFilter ¶
type FindingFilter struct {
ScanID string
Severity *core.Severity
Category *core.Category
Status core.Status
Fingerprint string
Limit int
}
FindingFilter narrows ListFindings. Zero values mean "any".
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is a fixed-size ring buffer of scans. When full, the oldest scan is overwritten. It is the hot-path store and the fallback with no DB.
func (*Memory) LatestScan ¶
func (*Memory) ListFindings ¶
type SQLite ¶
type SQLite struct {
// contains filtered or unexported fields
}
SQLite is a durable Store backed by pure-Go SQLite (no CGo).
func OpenSQLite ¶
OpenSQLite opens (or creates) the database at path and migrates the schema.
func (*SQLite) LatestScan ¶
func (*SQLite) ListFindings ¶
type Store ¶
type Store interface {
// SaveScan inserts or replaces a scan, including its findings.
SaveScan(ctx context.Context, s core.ScanResult) error
GetScan(ctx context.Context, id string) (core.ScanResult, error)
// ListScans returns scans newest first, without findings populated.
ListScans(ctx context.Context, limit int) ([]core.ScanResult, error)
// LatestScan returns the newest scan for a target name.
LatestScan(ctx context.Context, target string) (core.ScanResult, error)
ListFindings(ctx context.Context, f FindingFilter) ([]core.Finding, error)
// Prune deletes scans that finished before the cutoff and returns how many.
Prune(ctx context.Context, before time.Time) (int, error)
Close() error
}
Store persists scans and findings. Implementations are safe for concurrent use.