server

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package server provides an HTTP server for the vulnerability dashboard. All assets (templates, CSS, JavaScript) are embedded in the binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port    int
	Target  string
	Version string
}

Config contains server configuration.

type DashboardData

type DashboardData struct {
	PageData
	Stats      *DashboardStats
	Registries []*RegistryStat
	Recent     []*RecentImage
}

DashboardData contains data for the dashboard page.

type DashboardStats

type DashboardStats struct {
	TotalImages    int       `json:"total_images"`
	TotalDigests   int       `json:"total_digests"`
	TotalExposures int       `json:"total_exposures"`
	TotalPackages  int       `json:"total_packages"`
	LastScan       time.Time `json:"last_scan"`
	CriticalCount  int       `json:"critical_count"`
	HighCount      int       `json:"high_count"`
	MediumCount    int       `json:"medium_count"`
	LowCount       int       `json:"low_count"`
	FixableCount   int       `json:"fixable_count"`
	UnfixableCount int       `json:"unfixable_count"`
}

DashboardStats contains overall statistics for the dashboard.

type DigestInfo

type DigestInfo struct {
	Digest    string    `json:"digest"`
	LastScan  time.Time `json:"last_scan"`
	Exposures int       `json:"exposures"`
	Packages  int       `json:"packages"`
	MaxScore  float32   `json:"max_score"`
	Critical  int       `json:"critical"`
	High      int       `json:"high"`
	Medium    int       `json:"medium"`
	Low       int       `json:"low"`
	Sources   []string  `json:"sources"`
}

DigestInfo contains information about a specific digest.

type ExposureInfo

type ExposureInfo struct {
	Exposure string    `json:"exposure"`
	Severity string    `json:"severity"`
	Score    float32   `json:"score"`
	Package  string    `json:"package"`
	Version  string    `json:"version"`
	Source   string    `json:"source"`
	Fixed    bool      `json:"fixed"`
	LastScan time.Time `json:"last_scan"`
}

ExposureInfo contains information about a vulnerability exposure.

type ExposuresData

type ExposuresData struct {
	PageData
	Image     string
	Digest    string
	Exposures []*ExposureInfo
	Total     int
}

ExposuresData contains data for the exposures page.

type ImageDetail

type ImageDetail struct {
	Image   string        `json:"image"`
	Digests []*DigestInfo `json:"digests"`
}

ImageDetail contains detailed information about an image.

type ImageDetailData

type ImageDetailData struct {
	PageData
	Detail     *ImageDetail
	TimeSeries []*TimeSeriesPoint
}

ImageDetailData contains data for the image detail page.

type ImagesData

type ImagesData struct {
	PageData
	Images       []*RecentImage
	Search       string
	Total        int
	ShowTagChart bool
	BaseImage    string
	TagSeries    []*TagDataPoint
}

ImagesData contains data for the images page.

type PageData

type PageData struct {
	Title   string
	Version string
	Target  string
}

PageData contains common data for all pages.

type Queries

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

Queries encapsulates database queries for the dashboard.

func NewQueries

func NewQueries(db *sql.DB) *Queries

NewQueries creates a new Queries instance.

func (*Queries) GetDashboardStats

func (q *Queries) GetDashboardStats(ctx context.Context) (*DashboardStats, error)

GetDashboardStats returns overall dashboard statistics.

func (*Queries) GetExposures

func (q *Queries) GetExposures(ctx context.Context, image, digest string) ([]*ExposureInfo, error)

GetExposures returns exposures for a specific image and digest.

func (*Queries) GetImageDetail

func (q *Queries) GetImageDetail(ctx context.Context, image string) (*ImageDetail, error)

GetImageDetail returns detailed information about an image.

func (*Queries) GetRecentImages

func (q *Queries) GetRecentImages(ctx context.Context, limit int) ([]*RecentImage, error)

GetRecentImages returns the most recently scanned images.

func (*Queries) GetRegistryStats

func (q *Queries) GetRegistryStats(ctx context.Context, limit int) ([]*RegistryStat, error)

GetRegistryStats returns statistics grouped by registry.

func (*Queries) GetTimeSeries

func (q *Queries) GetTimeSeries(ctx context.Context, image string) ([]*TimeSeriesPoint, error)

GetTimeSeries returns vulnerability counts over time for an image.

func (*Queries) SearchImages

func (q *Queries) SearchImages(ctx context.Context, pattern string, limit int) ([]*RecentImage, error)

SearchImages searches for images matching a pattern.

type RecentImage

type RecentImage struct {
	Image     string    `json:"image"`
	Digest    string    `json:"digest"`
	LastScan  time.Time `json:"last_scan"`
	Exposures int       `json:"exposures"`
	MaxScore  float32   `json:"max_score"`
	Critical  int       `json:"critical"`
	High      int       `json:"high"`
	Medium    int       `json:"medium"`
	Low       int       `json:"low"`
}

RecentImage contains information about a recently scanned image.

type RegistryStat

type RegistryStat struct {
	Registry      string `json:"registry"`
	ImageCount    int    `json:"image_count"`
	ExposureCount int    `json:"exposure_count"`
}

RegistryStat contains statistics for a single registry.

type Server

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

Server represents the HTTP server for the dashboard.

func New

func New(cfg *Config) (*Server, error)

New creates a new Server instance.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the server address (for testing).

func (*Server) Close

func (s *Server) Close() error

Close closes the server and database connection.

func (*Server) DB

func (s *Server) DB() *sql.DB

DB returns the database connection (for testing).

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the HTTP server.

type TagDataPoint added in v0.10.0

type TagDataPoint struct {
	Tag      string `json:"tag"`
	Total    int    `json:"total"`
	Critical int    `json:"critical"`
	High     int    `json:"high"`
	Medium   int    `json:"medium"`
	Low      int    `json:"low"`
}

TagDataPoint contains vulnerability data for a single tag.

type TimeSeriesPoint

type TimeSeriesPoint struct {
	Date     string `json:"date"`
	Total    int    `json:"total"`
	Critical int    `json:"critical"`
	High     int    `json:"high"`
	Medium   int    `json:"medium"`
	Low      int    `json:"low"`
}

TimeSeriesPoint contains vulnerability counts for a specific date.

Jump to

Keyboard shortcuts

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