database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package database provides SQLite storage for scan history and vulnerability trends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateScanID

func GenerateScanID() string

GenerateScanID creates a unique scan ID

func MarshalSummary

func MarshalSummary(summary interface{}) string

MarshalSummary converts a summary to JSON string

Types

type DB

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

DB wraps the SQLite database connection

func Open

func Open(projectPath string) (*DB, error)

Open opens or creates the SQLite database in the project directory

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) DiffScans

func (db *DB) DiffScans(orgID, projectPath string) (*ScanDiff, error)

DiffScans compares the two most recent scans for a project, filtered by org

func (*DB) GetScan

func (db *DB) GetScan(id string) (*Scan, error)

GetScan retrieves a scan by ID

func (*DB) GetTrends

func (db *DB) GetTrends(orgID, projectPath string, days int) ([]*TrendPoint, error)

GetTrends returns vulnerability trends for the last N days, filtered by org

func (*DB) GetVulnerabilitiesForScan

func (db *DB) GetVulnerabilitiesForScan(scanID string) ([]*ScanVuln, error)

GetVulnerabilitiesForScan returns all vulnerabilities for a given scan

func (*DB) ListScans

func (db *DB) ListScans(orgID, projectPath string, limit int) ([]*Scan, error)

ListScans returns all scans for a project, filtered by org and ordered by timestamp desc

func (*DB) SaveScan

func (db *DB) SaveScan(scan *Scan) error

SaveScan saves a scan result to the database

func (*DB) SaveVulnerability

func (db *DB) SaveVulnerability(scanID, cveID, pkg, status, severity string) error

SaveVulnerability saves a vulnerability for a scan

type Scan

type Scan struct {
	ID          string    `json:"id"`
	OrgID       string    `json:"org_id"` // Tenant isolation
	ProjectPath string    `json:"project_path"`
	Timestamp   time.Time `json:"timestamp"`
	TotalVulns  int       `json:"total_vulns"`
	Reachable   int       `json:"reachable"`
	Unreachable int       `json:"unreachable"`
	SummaryJSON string    `json:"summary_json,omitempty"`
}

Scan represents a stored analysis scan

type ScanDiff

type ScanDiff struct {
	CurrentScanID  string      `json:"current_scan_id"`
	PreviousScanID string      `json:"previous_scan_id"`
	NewVulns       []*ScanVuln `json:"new"`
	FixedVulns     []*ScanVuln `json:"fixed"`
	CurrentTotal   int         `json:"current_total"`
	PreviousTotal  int         `json:"previous_total"`
	RiskDelta      string      `json:"risk_delta"`
}

ScanDiff represents the difference between two scans

type ScanVuln

type ScanVuln struct {
	CveID    string `json:"cve_id"`
	Package  string `json:"package"`
	Status   string `json:"status"`
	Severity string `json:"severity"`
}

ScanVuln represents a vulnerability record from a scan

type TrendPoint

type TrendPoint struct {
	Date        string `json:"date"`
	TotalVulns  int    `json:"total_vulns"`
	Reachable   int    `json:"reachable"`
	Unreachable int    `json:"unreachable"`
}

TrendPoint represents a single data point for vulnerability trends

Jump to

Keyboard shortcuts

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