nvd

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package nvd provides a vulnerability source backed by the NIST NVD API.

Index

Constants

View Source
const (
	DefaultAPIURL  = "https://services.nvd.nist.gov/rest/json/cves/2.0"
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Source)

Option configures a Source.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the NVD API key. Optional but recommended to avoid rate limits. Without a key: 5 requests per 30 seconds. With a key: 50 requests per 30 seconds.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets a custom API base URL.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets a custom HTTP client.

type Source

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

Source implements vulns.Source using the NVD API. Note: NVD is CVE-focused and queries by CPE, not package name directly. PURL-to-CPE mapping is approximate.

func New

func New(opts ...Option) *Source

New creates a new NVD source.

func (*Source) Get

func (s *Source) Get(ctx context.Context, id string) (*vulns.Vulnerability, error)

Get fetches a specific vulnerability by CVE ID.

func (*Source) Name

func (s *Source) Name() string

Name returns "nvd".

func (*Source) Query

func (s *Source) Query(ctx context.Context, p *purl.PURL) ([]vulns.Vulnerability, error)

Query returns vulnerabilities affecting the package identified by the PURL. NVD uses CPE for matching, so this converts the PURL to a CPE search.

func (*Source) QueryBatch

func (s *Source) QueryBatch(ctx context.Context, purls []*purl.PURL) ([][]vulns.Vulnerability, error)

QueryBatch queries multiple packages. NVD doesn't have a batch API, so this makes individual requests with rate limiting.

Jump to

Keyboard shortcuts

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