storage

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage persists ToolTrust Scanner results to a SQLite database. It uses modernc.org/sqlite — a pure-Go driver with no CGo dependency, making cross-compilation (linux/darwin/windows) straightforward.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScanRecord

type ScanRecord struct {
	ID        string
	ToolName  string
	Protocol  model.ProtocolType
	RiskScore int
	Grade     model.Grade
	Findings  []model.Issue
	ScannedAt time.Time
}

ScanRecord is the persisted form of a single tool scan.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store wraps a SQLite connection and exposes scan-result persistence.

func Open

func Open(dsn string) (*Store, error)

Open opens (or creates) a SQLite database at dsn and runs the schema migration. Use ":memory:" for tests.

func OpenContext

func OpenContext(ctx context.Context, dsn string) (*Store, error)

OpenContext is like Open but accepts an explicit context for the schema migration.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) Count

func (s *Store) Count(ctx context.Context) (int, error)

Count returns the total number of stored scan records.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (ScanRecord, error)

Get retrieves a single ScanRecord by ID. Returns sql.ErrNoRows if not found.

func (*Store) ListByGrade

func (s *Store) ListByGrade(ctx context.Context, grade model.Grade) ([]ScanRecord, error)

ListByGrade returns all scan records with the given grade, newest first.

func (*Store) Save

func (s *Store) Save(ctx context.Context, r ScanRecord) error

Save persists a ScanRecord. If a record with the same ID already exists it is replaced.

Jump to

Keyboard shortcuts

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