session

package
v0.0.0-...-6656868 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package session provides persistence for scan state, allowing scans to be saved, resumed, and reviewed.

Index

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

func (s *SQLiteStore) Cleanup(ctx context.Context, maxAge time.Duration) (int64, error)

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

func (s *SQLiteStore) Load(ctx context.Context, targetURL string) (*ScanState, error)

Load retrieves the most recently updated ScanState for the given target URL. Returns (nil, nil) if no session is found.

func (*SQLiteStore) LoadByID

func (s *SQLiteStore) LoadByID(ctx context.Context, id string) (*ScanState, error)

LoadByID retrieves a ScanState by its unique ID. Returns (nil, nil) if no session is found.

func (*SQLiteStore) Save

func (s *SQLiteStore) Save(ctx context.Context, state *ScanState) error

Save persists a ScanState to the database. If the state's ID is empty, a new UUID is generated and assigned.

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.

Jump to

Keyboard shortcuts

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