viz

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package viz provides visualization functions for vulnerability analysis data. It uses gonum/plot for generating charts and graphs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorConsensus = color.RGBA{R: 76, G: 175, B: 80, A: 255}  // Green
	ColorPartial   = color.RGBA{R: 255, G: 193, B: 7, A: 255}  // Amber
	ColorUnique    = color.RGBA{R: 244, G: 67, B: 54, A: 255}  // Red
	ColorDefault   = color.RGBA{R: 33, G: 150, B: 243, A: 255} // Blue
)

Colors for different categories

Functions

func CreateBarChart

func CreateBarChart(data []BarData, config BarChartConfig) (*plot.Plot, error)

CreateBarChart creates a bar chart.

func CreateBoxPlot

func CreateBoxPlot(categories []CategoryData, config BoxPlotConfig) (*plot.Plot, error)

CreateBoxPlot creates a box plot comparing EPSS score distributions across categories.

func CreateHistogram

func CreateHistogram(scores []float64, config HistogramConfig) (*plot.Plot, error)

CreateHistogram creates a histogram of EPSS scores.

func CreateScatterPlot

func CreateScatterPlot(points []Point, config ScatterConfig) (*plot.Plot, error)

CreateScatterPlot creates a scatter plot.

func SavePlot

func SavePlot(p *plot.Plot, filename string, width, height vg.Length) error

SavePlot saves a plot to a file.

Types

type BarChartConfig

type BarChartConfig struct {
	Title    string
	XLabel   string
	YLabel   string
	Width    vg.Length
	Height   vg.Length
	FileName string
}

BarChartConfig configures bar chart generation.

func DefaultBarChartConfig

func DefaultBarChartConfig() BarChartConfig

DefaultBarChartConfig returns default bar chart configuration.

type BarData

type BarData struct {
	Label string
	Value float64
	Color color.Color
}

BarData represents a single bar in a bar chart.

func CreateConsensusBarData

func CreateConsensusBarData(dist ConsensusTypeDistribution) []BarData

CreateConsensusBarData prepares data for consensus type distribution.

func CreateEPSSBucketData

func CreateEPSSBucketData(buckets EPSSPercentileBuckets) []BarData

CreateEPSSBucketData prepares data for EPSS bucket distribution.

func CreateSeverityPieData

func CreateSeverityPieData(dist SeverityDistribution) []BarData

CreateSeverityPieData prepares data for severity distribution visualization.

type BoxPlotConfig

type BoxPlotConfig struct {
	Title    string
	YLabel   string
	Width    vg.Length
	Height   vg.Length
	FileName string
}

BoxPlotConfig configures box plot generation.

func DefaultBoxPlotConfig

func DefaultBoxPlotConfig() BoxPlotConfig

DefaultBoxPlotConfig returns default box plot configuration.

type CategoryData

type CategoryData struct {
	Name   string
	Scores []float64
	Color  color.Color
}

CategoryData represents data for a single category.

type ConsensusTypeDistribution

type ConsensusTypeDistribution struct {
	Consensus int
	Partial   int
	Unique    int
}

ConsensusTypeDistribution represents vulnerability counts by consensus type.

type EPSSPercentileBuckets

type EPSSPercentileBuckets struct {
	Low      int // 0-25th percentile
	Medium   int // 25-50th percentile
	High     int // 50-75th percentile
	Critical int // 75-100th percentile
}

EPSSPercentileBuckets groups EPSS scores into percentile buckets.

func BucketScores

func BucketScores(scores []float64) EPSSPercentileBuckets

BucketScores groups EPSS scores into percentile buckets.

type HistogramConfig

type HistogramConfig struct {
	Title    string
	XLabel   string
	YLabel   string
	Bins     int
	Width    vg.Length
	Height   vg.Length
	FileName string
}

HistogramConfig configures histogram generation.

func DefaultHistogramConfig

func DefaultHistogramConfig() HistogramConfig

DefaultHistogramConfig returns default histogram configuration.

type Point

type Point struct {
	X, Y float64
}

Point represents a 2D point.

type ScatterConfig

type ScatterConfig struct {
	Title    string
	XLabel   string
	YLabel   string
	Width    vg.Length
	Height   vg.Length
	FileName string
}

ScatterConfig configures scatter plot generation.

func DefaultScatterConfig

func DefaultScatterConfig() ScatterConfig

DefaultScatterConfig returns default scatter plot configuration.

type SeverityDistribution

type SeverityDistribution struct {
	Critical int
	High     int
	Medium   int
	Low      int
	Unknown  int
}

SeverityDistribution represents vulnerability counts by severity.

type SummaryStats

type SummaryStats struct {
	TotalVulnerabilities  int
	UniqueVulnerabilities int
	ConsensusCount        int
	PartialCount          int
	UniqueCount           int
	MeanEPSS              float64
	MedianEPSS            float64
	HighRiskCount         int // EPSS > 0.5
	CriticalRiskCount     int // EPSS > 0.75
}

SummaryStats contains statistics for a report.

func CalculateSummaryStats

func CalculateSummaryStats(epssScores []float64, consensus, partial, unique int) SummaryStats

CalculateSummaryStats calculates summary statistics from EPSS scores and consensus counts.

Jump to

Keyboard shortcuts

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