Documentation
¶
Overview ¶
Package session provides persistence for scan state, allowing scans to be saved, resumed, and reviewed.
Index ¶
- type SQLiteStore
- func (s *SQLiteStore) Cleanup(ctx context.Context, maxAge time.Duration) (int64, error)
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) Delete(ctx context.Context, id string) error
- func (s *SQLiteStore) List(ctx context.Context) ([]*ScanSummary, error)
- func (s *SQLiteStore) Load(ctx context.Context, targetURL string) (*ScanState, error)
- func (s *SQLiteStore) LoadByID(ctx context.Context, id string) (*ScanState, error)
- func (s *SQLiteStore) Save(ctx context.Context, state *ScanState) error
- type ScanState
- type ScanSummary
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements Store using SQLite via modernc.org/sqlite (pure Go).
func NewSQLiteStore ¶
func NewSQLiteStore(dbPath string) (*SQLiteStore, error)
NewSQLiteStore creates a new SQLite-backed store. dbPath is the path to the SQLite database file; use ":memory:" for testing.
func (*SQLiteStore) Cleanup ¶
Cleanup removes sessions whose updated_at is older than maxAge from now. It returns the number of deleted sessions.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
Close closes the underlying database connection.
func (*SQLiteStore) Delete ¶
func (s *SQLiteStore) Delete(ctx context.Context, id string) error
Delete removes a session by its ID.
func (*SQLiteStore) List ¶
func (s *SQLiteStore) List(ctx context.Context) ([]*ScanSummary, error)
List returns a lightweight summary of all stored sessions.
func (*SQLiteStore) Load ¶
Load retrieves the most recently updated ScanState for the given target URL. Returns (nil, nil) if no session is found.
type ScanState ¶
type ScanState struct {
ID string `json:"id"`
TargetURL string `json:"target_url"`
Target interface{} `json:"target"` // Serialized ScanTarget
Vulnerabilities []interface{} `json:"vulnerabilities"` // Serialized Vulnerabilities
DBMS string `json:"dbms"`
DBMSVersion string `json:"dbms_version"`
Config map[string]interface{} `json:"config"`
Progress float64 `json:"progress"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ScanState captures everything needed to resume a scan.
type ScanSummary ¶
type ScanSummary struct {
ID string `json:"id"`
TargetURL string `json:"target_url"`
Progress float64 `json:"progress"`
DBMS string `json:"dbms"`
UpdatedAt time.Time `json:"updated_at"`
}
ScanSummary is a lightweight session overview.
type Store ¶
type Store interface {
Save(ctx context.Context, state *ScanState) error
Load(ctx context.Context, targetURL string) (*ScanState, error)
LoadByID(ctx context.Context, id string) (*ScanState, error)
List(ctx context.Context) ([]*ScanSummary, error)
Delete(ctx context.Context, id string) error
Close() error
}
Store persists and retrieves scan state.