store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package store provides SQLite storage for Overseer's vulnerability tracking.

Index

Constants

View Source
const (
	ScanStatusRunning   = "running"
	ScanStatusCompleted = "completed"
	ScanStatusFailed    = "failed"
)

ScanStatus constants for scan state tracking.

View Source
const (
	SeverityCritical = "CRITICAL"
	SeverityHigh     = "HIGH"
	SeverityMedium   = "MEDIUM"
	SeverityLow      = "LOW"
	SeverityUnknown  = "UNKNOWN"
)

Severity constants for vulnerability classification.

Variables

This section is empty.

Functions

func DefaultDBPath

func DefaultDBPath() (string, error)

DefaultDBPath returns the default database path (~/.local/share/ovrse/overseer.db). Uses XDG_DATA_HOME on Linux/macOS, LocalAppData on Windows.

Types

type Package

type Package struct {
	ID        int64  `json:"id"`
	ProjectID int64  `json:"project_id"`
	Name      string `json:"name"`
	Version   string `json:"version"`
	Ecosystem string `json:"ecosystem"` // npm, go, pip, cargo, etc.
	LockFile  string `json:"lock_file,omitempty"`
}

Package represents a detected package in a project.

type Project

type Project struct {
	ID            int64      `json:"id"`
	Path          string     `json:"path"`
	Name          string     `json:"name,omitempty"`
	Ecosystem     string     `json:"ecosystem,omitempty"` // npm, go, pip, etc.
	AddedAt       time.Time  `json:"added_at"`
	LastScannedAt *time.Time `json:"last_scanned_at,omitempty"`
}

Project represents a monitored project directory.

type ProjectSummary

type ProjectSummary struct {
	Project
	TotalPackages int            `json:"total_packages"`
	TotalVulns    int            `json:"total_vulns"`
	BySeverity    map[string]int `json:"by_severity"` // severity -> count
}

ProjectSummary provides a summary of vulnerabilities in a project.

type Scan

type Scan struct {
	ID              int64      `json:"id"`
	ProjectID       int64      `json:"project_id"`
	StartedAt       time.Time  `json:"started_at"`
	CompletedAt     *time.Time `json:"completed_at,omitempty"`
	PackagesScanned int        `json:"packages_scanned"`
	VulnsFound      int        `json:"vulns_found"`
	Status          string     `json:"status"` // running, completed, failed
}

Scan represents a scan history entry.

type Store

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

Store provides SQLite storage for Overseer data.

func New

func New(dbPath string) (*Store, error)

New creates a new Store with the given database path. If dbPath is empty, uses the default path.

func (*Store) AddProject

func (s *Store) AddProject(path string) (*Project, error)

AddProject adds a new project to monitor.

func (*Store) ClearPackagesForProject

func (s *Store) ClearPackagesForProject(projectID int64) error

ClearPackagesForProject removes all packages for a project (before re-scanning).

func (*Store) ClearVulnerabilitiesForPackage

func (s *Store) ClearVulnerabilitiesForPackage(packageID int64) error

ClearVulnerabilitiesForPackage removes all vulnerabilities for a package.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) CompleteScan

func (s *Store) CompleteScan(scanID int64, packagesScanned, vulnsFound int) error

CompleteScan marks a scan as completed.

func (*Store) DismissVulnerability

func (s *Store) DismissVulnerability(vulnID int64) error

DismissVulnerability marks a vulnerability as dismissed.

func (*Store) FailScan

func (s *Store) FailScan(scanID int64) error

FailScan marks a scan as failed.

func (*Store) GetLastScan

func (s *Store) GetLastScan(projectID int64) (*Scan, error)

GetLastScan returns the most recent scan for a project.

func (*Store) GetOverallSummary

func (s *Store) GetOverallSummary() (map[string]int, int, error)

GetOverallSummary returns vulnerability summary across all projects.

func (*Store) GetPackagesByProject

func (s *Store) GetPackagesByProject(projectID int64) ([]Package, error)

GetPackagesByProject returns all packages for a project.

func (*Store) GetProject

func (s *Store) GetProject(id int64) (*Project, error)

GetProject retrieves a project by ID.

func (*Store) GetProjectByPath

func (s *Store) GetProjectByPath(path string) (*Project, error)

GetProjectByPath retrieves a project by its path.

func (*Store) GetProjectSummary

func (s *Store) GetProjectSummary(projectID int64) (*ProjectSummary, error)

GetProjectSummary returns vulnerability summary for a project.

func (*Store) GetVulnerabilityCount

func (s *Store) GetVulnerabilityCount() (int, error)

GetVulnerabilityCount returns the total count of active vulnerabilities.

func (*Store) ListProjects

func (s *Store) ListProjects() ([]Project, error)

ListProjects returns all monitored projects.

func (*Store) ListVulnerabilities

func (s *Store) ListVulnerabilities(filter VulnFilter) ([]VulnResult, error)

ListVulnerabilities returns vulnerabilities matching the filter.

func (*Store) Path

func (s *Store) Path() string

Path returns the database file path.

func (*Store) RecordVulnerability

func (s *Store) RecordVulnerability(vuln Vulnerability) (*Vulnerability, error)

RecordVulnerability records a vulnerability for a package.

func (*Store) RemoveProject

func (s *Store) RemoveProject(path string) error

RemoveProject removes a project and all its data.

func (*Store) StartScan

func (s *Store) StartScan(projectID int64) (*Scan, error)

StartScan creates a new scan record.

func (*Store) UndismissVulnerability

func (s *Store) UndismissVulnerability(vulnID int64) error

UndismissVulnerability removes the dismissed status from a vulnerability.

func (*Store) UpdateProjectEcosystem

func (s *Store) UpdateProjectEcosystem(projectID int64, ecosystem string) error

UpdateProjectEcosystem updates the ecosystem for a project.

func (*Store) UpdateProjectScanTime

func (s *Store) UpdateProjectScanTime(projectID int64) error

UpdateProjectScanTime updates the last scanned timestamp for a project.

func (*Store) UpsertPackage

func (s *Store) UpsertPackage(pkg Package) (*Package, error)

UpsertPackage inserts or updates a package in a project. Unique key is (project_id, name, version, ecosystem) to support multiple versions.

type VulnFilter

type VulnFilter struct {
	ProjectID   *int64   // Filter by specific project
	ProjectPath string   // Filter by project path
	Severity    []string // Filter by severity levels
	CVEID       string   // Filter by specific CVE
	Dismissed   *bool    // Filter dismissed status (nil = all, true = dismissed only, false = active only)
	Limit       int      // Max results (0 = unlimited)
}

VulnFilter provides filtering options for vulnerability queries.

type VulnResult

type VulnResult struct {
	Vulnerability
	PackageName    string `json:"package_name"`
	PackageVersion string `json:"package_version"`
	PackageEco     string `json:"package_ecosystem"`
	ProjectPath    string `json:"project_path"`
	ProjectName    string `json:"project_name,omitempty"`
}

VulnResult represents a vulnerability with its associated package and project info.

type Vulnerability

type Vulnerability struct {
	ID          int64      `json:"id"`
	PackageID   int64      `json:"package_id"`
	CVEID       string     `json:"cve_id"`
	Severity    string     `json:"severity,omitempty"`   // CRITICAL, HIGH, MEDIUM, LOW
	CVSSScore   *float64   `json:"cvss_score,omitempty"` // nil if unknown
	Summary     string     `json:"summary,omitempty"`
	FixVersion  string     `json:"fix_version,omitempty"`
	DetectedAt  time.Time  `json:"detected_at"`
	DismissedAt *time.Time `json:"dismissed_at,omitempty"`
}

Vulnerability represents a detected vulnerability in a package.

Jump to

Keyboard shortcuts

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