Documentation
¶
Overview ¶
Package provider defines the core Provider interface that all vulnerability data providers (NVD, GitHub, etc.) must implement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global provider registry.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// RootDir is the base directory for all provider data.
// Each provider creates a subdirectory: {RootDir}/{ProviderName}/
RootDir string
// Workers is the number of concurrent workers for fetching.
// Optimal values: NVD=10 (90-day partitions), GitHub=1 (avoid abuse detection)
Workers int
// RequestTimeout is the timeout for individual HTTP requests.
RequestTimeout time.Duration
// RetryAttempts is the number of retry attempts for failed requests.
RetryAttempts int
// Debug enables verbose logging of rate limits, timing, and headers.
Debug bool
}
Config holds common configuration for all providers.
type FetchFunc ¶
type FetchFunc func(ctx context.Context, writer *store.SQLiteWriter) error
FetchFunc is the provider-specific fetch function that writes records. The provider receives a SQLiteWriter and is responsible for writing all records.
type GitHubConfig ¶
type GitHubConfig struct {
Config
// Token is the GitHub personal access token.
// Required for GraphQL API access.
Token string
// AdvisoriesPerPage is the number of advisories per GraphQL request.
// Max is 100.
AdvisoriesPerPage int
}
GitHubConfig extends Config with GitHub-specific settings.
type NVDConfig ¶
type NVDConfig struct {
Config
// APIKey is the NVD API key for higher rate limits.
// Without key: 5 req/30s, With key: 50 req/30s
APIKey string
// ResultsPerPage is the maximum results per API request.
// NVD max is 2000.
ResultsPerPage int
}
NVDConfig extends Config with NVD-specific settings.
type Provider ¶
type Provider interface {
// Name returns the provider identifier (e.g., "nvd", "github").
// Used for logging, metrics, and directory naming.
Name() string
// FetchAll downloads all data from the upstream source (cold boot).
// This should use partitioning and worker pools for maximum throughput.
FetchAll(ctx context.Context) error
// FetchIncremental downloads only updates since lastUpdated.
// Uses API-specific incremental mechanisms (lastModStartDate for NVD,
// updatedSince for GitHub).
FetchIncremental(ctx context.Context, lastUpdated time.Time) error
// ResultsPath returns the path to the SQLite database.
// Format: {root}/{provider}/results/{provider}-input.db
ResultsPath() string
// MetadataPath returns the path to metadata.json.
// Format: {root}/{provider}/metadata.json
MetadataPath() string
}
Provider defines the contract for vulnerability data providers. Each provider fetches data from an upstream source and writes it to SQLite in a format compatible with grype-db.
type ProviderFactory ¶
ProviderFactory is a function that creates a new Provider instance.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maintains a mapping of provider names to their factories.
func (*Registry) Get ¶
func (r *Registry) Get(name string) (ProviderFactory, error)
Get retrieves a provider factory by name.
func (*Registry) Register ¶
func (r *Registry) Register(name string, factory ProviderFactory)
Register adds a provider factory to the registry.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package epss implements the Exploit Prediction Scoring System provider.
|
Package epss implements the Exploit Prediction Scoring System provider. |
|
Package github implements the GitHub Security Advisories provider.
|
Package github implements the GitHub Security Advisories provider. |
|
Package kev implements the CISA Known Exploited Vulnerabilities provider.
|
Package kev implements the CISA Known Exploited Vulnerabilities provider. |
|
Package nvd implements the NVD vulnerability data provider.
|
Package nvd implements the NVD vulnerability data provider. |
|
Package ubuntu implements the Ubuntu CVE security provider.
|
Package ubuntu implements the Ubuntu CVE security provider. |
|
Package wolfi implements the Wolfi/Chainguard security provider.
|
Package wolfi implements the Wolfi/Chainguard security provider. |