Documentation
¶
Overview ¶
Package vulns provides a unified interface for querying vulnerability data from various sources. It uses PURL (Package URL) as the primary identifier and OSV (Open Source Vulnerabilities) format as the canonical data model.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AffectedVersionRange ¶
AffectedVersionRange returns a vers range string representing the affected versions. Events are processed sequentially, emitting a constraint for each introduced/fixed or introduced/lastAffected pair.
Types ¶
type Affected ¶
type Affected struct {
Package Package `json:"package"`
Ranges []Range `json:"ranges,omitempty"`
Versions []string `json:"versions,omitempty"`
EcosystemSpecific map[string]any `json:"ecosystem_specific,omitempty"`
DatabaseSpecific map[string]any `json:"database_specific,omitempty"`
}
Affected describes which package versions are affected.
type CVSS ¶
CVSS holds parsed CVSS information.
func CVSSFromSeverity ¶
CVSSFromSeverity extracts and parses CVSS information from a Severity entry.
type Credit ¶
type Credit struct {
Name string `json:"name"`
Contact []string `json:"contact,omitempty"`
Type string `json:"type,omitempty"`
}
Credit gives credit to vulnerability reporters/fixers.
type Event ¶
type Event struct {
Introduced string `json:"introduced,omitempty"`
Fixed string `json:"fixed,omitempty"`
LastAffected string `json:"last_affected,omitempty"`
Limit string `json:"limit,omitempty"`
}
Event is a version event (introduced, fixed, etc).
type Package ¶
type Package struct {
Ecosystem string `json:"ecosystem"`
Name string `json:"name"`
PURL string `json:"purl,omitempty"`
}
Package identifies a package.
type Source ¶
type Source interface {
// Name returns the name of this source (e.g., "osv", "nvd").
Name() string
// Query returns vulnerabilities affecting the package identified by the PURL.
// If the PURL includes a version, only vulnerabilities affecting that version
// are returned. If no version is specified, all known vulnerabilities for the
// package are returned.
Query(ctx context.Context, p *purl.PURL) ([]Vulnerability, error)
// QueryBatch queries multiple packages at once. Returns a slice of results
// in the same order as the input PURLs.
QueryBatch(ctx context.Context, purls []*purl.PURL) ([][]Vulnerability, error)
// Get fetches a specific vulnerability by its ID.
Get(ctx context.Context, id string) (*Vulnerability, error)
}
Source represents a vulnerability data source.
type Vulnerability ¶
type Vulnerability struct {
ID string `json:"id"`
Summary string `json:"summary,omitempty"`
Details string `json:"details,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Modified time.Time `json:"modified"`
Published time.Time `json:"published"`
Withdrawn *time.Time `json:"withdrawn,omitempty"`
References []Reference `json:"references,omitempty"`
Affected []Affected `json:"affected,omitempty"`
Severity []Severity `json:"severity,omitempty"`
Credits []Credit `json:"credits,omitempty"`
DatabaseSpecific map[string]any `json:"database_specific,omitempty"`
}
Vulnerability represents a security vulnerability in OSV format. This is the canonical format used across all sources.
func (*Vulnerability) CVSS ¶
func (v *Vulnerability) CVSS() *CVSS
CVSS returns parsed CVSS information from the vulnerability's severity data. Returns nil if no CVSS information is available.
func (*Vulnerability) CVSSScore ¶
func (v *Vulnerability) CVSSScore() float64
CVSSScore returns the highest CVSS score if available, or -1 if not.
func (*Vulnerability) FixedVersion ¶
func (v *Vulnerability) FixedVersion(ecosystem, name string) string
FixedVersion returns the first fixed version for the given package, if available.
func (*Vulnerability) IsVersionAffected ¶
func (v *Vulnerability) IsVersionAffected(ecosystem, name, version string) bool
IsVersionAffected checks if a specific version of a package is affected.
func (*Vulnerability) SeverityLevel ¶
func (v *Vulnerability) SeverityLevel() string
SeverityLevel returns a normalized severity level (critical, high, medium, low, unknown).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package depsdev provides a vulnerability source backed by Google's deps.dev API.
|
Package depsdev provides a vulnerability source backed by Google's deps.dev API. |
|
Package ghsa provides a vulnerability source backed by the GitHub Security Advisory API.
|
Package ghsa provides a vulnerability source backed by the GitHub Security Advisory API. |
|
Package grypedb provides a vulnerability source backed by the Grype vulnerability database.
|
Package grypedb provides a vulnerability source backed by the Grype vulnerability database. |
|
Package nvd provides a vulnerability source backed by the NIST NVD API.
|
Package nvd provides a vulnerability source backed by the NIST NVD API. |
|
Package osv provides a vulnerability source backed by the OSV API.
|
Package osv provides a vulnerability source backed by the OSV API. |
|
Package vl provides a vulnerability source backed by vulnerability-lookup.org (CIRCL).
|
Package vl provides a vulnerability source backed by vulnerability-lookup.org (CIRCL). |
|
Package vulncheck provides a vulnerability source backed by the VulnCheck API.
|
Package vulncheck provides a vulnerability source backed by the VulnCheck API. |