filter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package filter provides CVSS score-based filtering for vulnerabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatScore

func FormatScore(score float64) string

FormatScore formats a CVSS score for display.

Types

type Filter

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

Filter applies CVSS score filtering to vulnerabilities.

func NewFilter

func NewFilter(nvdClient *nvd.Client, opts ...FilterOption) *Filter

NewFilter creates a new Filter with the given options.

func (*Filter) Apply

func (f *Filter) Apply(ctx context.Context, result *govulncheck.Result) (*FilterResult, error)

Apply filters vulnerabilities based on CVSS scores.

type FilterOption

type FilterOption func(*Filter)

FilterOption configures the Filter.

func WithCVSSVersion

func WithCVSSVersion(version nvd.CVSSVersion) FilterOption

WithCVSSVersion sets the preferred CVSS version.

func WithCalledOnly

func WithCalledOnly(called bool) FilterOption

WithCalledOnly filters to only include vulnerabilities that are actually called.

func WithFailOnNoCVSS

func WithFailOnNoCVSS(fail bool) FilterOption

WithFailOnNoCVSS configures whether to fail when CVSS score is unavailable.

func WithMaxAgeYears

func WithMaxAgeYears(years int) FilterOption

WithMaxAgeYears sets the maximum age filter in years (0 = no limit).

func WithThreshold

func WithThreshold(threshold float64) FilterOption

WithThreshold sets the CVSS score threshold.

type FilterResult

type FilterResult struct {
	Threshold       float64
	CVSSVersion     nvd.CVSSVersion
	MaxAgeYears     int
	TotalVulns      int
	FilteredVulns   int
	HighestScore    float64
	Vulnerabilities []*VulnerabilityInfo
	NoCVSSVulns     []*VulnerabilityInfo
	SkippedVulns    []*VulnerabilityInfo
	TooOldVulns     []*VulnerabilityInfo
	FailOnNoCVSS    bool
	ShouldFail      bool
}

FilterResult contains the results of vulnerability filtering.

type Severity

type Severity string

Severity represents CVSS severity levels.

const (
	SeverityCritical Severity = "CRITICAL"
	SeverityHigh     Severity = "HIGH"
	SeverityMedium   Severity = "MEDIUM"
	SeverityLow      Severity = "LOW"
	SeverityNone     Severity = "NONE"
)

func GetSeverity

func GetSeverity(score float64) Severity

GetSeverity returns the severity level for a CVSS score.

func (Severity) String

func (s Severity) String() string

String returns the string representation of the severity.

type VulnerabilityInfo

type VulnerabilityInfo struct {
	OSVID        string
	CVEIDs       []string
	Summary      string
	Details      string
	CVSSScore    *nvd.CVSSScore
	Modules      []string
	FixedVersion string
	Finding      *govulncheck.Finding
	OSV          *govulncheck.OSV
	Published    time.Time
}

VulnerabilityInfo aggregates vulnerability data from multiple sources.

Jump to

Keyboard shortcuts

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