Documentation
¶
Index ¶
- Variables
- func DownloadDatabase(dbDir string, ecosystems []string, progress func(eco string, done bool)) error
- type Affected
- type Aggregator
- func (a *Aggregator) Close()
- func (a *Aggregator) Lookup(ctx context.Context, cveID string) (*CVE, error)
- func (a *Aggregator) QueryByCPE(ctx context.Context, cpe string) ([]CVE, error)
- func (a *Aggregator) QueryPackage(ctx context.Context, ecosystem, pkg, version string) ([]CVE, error)
- func (a *Aggregator) QueryPackageBatch(ctx context.Context, packages []struct{ ... }) (map[string][]CVE, error)
- func (a *Aggregator) QueryRecent(ctx context.Context, since time.Time) ([]CVE, error)
- type CVE
- type CallSite
- type ExploitDBClient
- type Finding
- type GHSAClient
- type KEVClient
- type MatchedDep
- type NVDClient
- type OSVClient
- type OfflineDB
- type ScanResult
- type VerdictType
- type VersionRange
Constants ¶
This section is empty.
Variables ¶
var SupportedEcosystems = []string{
"npm", "PyPI", "Go", "Maven", "crates.io", "RubyGems", "Packagist", "NuGet",
}
SupportedEcosystems are the ecosystems we download from OSV.
Functions ¶
Types ¶
type Affected ¶
type Affected struct {
Ecosystem string `json:"ecosystem"` // "npm", "PyPI", "Go", "Maven", "crates.io", etc.
Package string `json:"package"` // Package name
Ranges []VersionRange `json:"ranges,omitempty"` // Affected version ranges
Versions []string `json:"versions,omitempty"` // Specific affected versions
Functions []string `json:"functions,omitempty"` // Vulnerable functions (if known)
}
Affected describes an affected package or product.
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator combines CVE data from multiple sources into a single unified view. Priority: GHSA for package version ranges, NVD for CVSS scores, OSV for ecosystem data, KEV for active exploitation status, ExploitDB/GitHub for PoC existence.
func NewAggregator ¶
func NewAggregator(nvdAPIKey, githubToken, cacheDir string, cacheTTLHours int) *Aggregator
func (*Aggregator) QueryByCPE ¶
QueryByCPE queries NVD for CVEs matching a CPE string. Used by the network scanner to match service versions.
func (*Aggregator) QueryPackage ¶
func (a *Aggregator) QueryPackage(ctx context.Context, ecosystem, pkg, version string) ([]CVE, error)
QueryPackage finds all CVEs affecting a specific package+version. This is the primary method used during codebase scanning.
func (*Aggregator) QueryPackageBatch ¶
func (a *Aggregator) QueryPackageBatch(ctx context.Context, packages []struct { Ecosystem string Name string Version string }) (map[string][]CVE, error)
QueryPackageBatch queries OSV for multiple packages at once. Returns a map of "ecosystem/package@version" -> []CVE.
func (*Aggregator) QueryRecent ¶
QueryRecent fetches CVEs published since a given date.
type CVE ¶
type CVE struct {
ID string `json:"id"` // e.g. "CVE-2026-31337"
Description string `json:"description"` // Human-readable description
Severity string `json:"severity"` // "CRITICAL", "HIGH", "MEDIUM", "LOW"
CVSSScore float64 `json:"cvss_score"` // 0.0 - 10.0
CVSSVector string `json:"cvss_vector,omitempty"`
Published time.Time `json:"published"`
Modified time.Time `json:"modified"`
References []string `json:"references,omitempty"` // URLs to advisories, patches
Affected []Affected `json:"affected"` // Which packages/products are affected
HasExploit bool `json:"has_exploit"` // PoC exists on ExploitDB
InTheWild bool `json:"in_the_wild"` // In CISA KEV (actively exploited)
Sources []string `json:"sources"` // Which data sources contributed
}
CVE represents a normalized vulnerability from any source.
type CallSite ¶
type CallSite struct {
File string `json:"file"`
Line int `json:"line"`
Function string `json:"function"` // The function being called
Snippet string `json:"snippet"` // The line of code
}
CallSite is a location in code where a vulnerable function is called.
type ExploitDBClient ¶
type ExploitDBClient struct {
// contains filtered or unexported fields
}
ExploitDBClient checks if a public exploit (PoC) exists for a CVE. Uses the ExploitDB website search since there's no official API. An alternative is to check GitHub for PoCs via the GitHub search API.
func NewExploitDBClient ¶
func NewExploitDBClient() *ExploitDBClient
func (*ExploitDBClient) HasExploit ¶
HasExploit checks if ExploitDB has a PoC for this CVE. Uses a simple HTTP check against the ExploitDB search.
type Finding ¶
type Finding struct {
CVE CVE `json:"cve"`
MatchedDep MatchedDep `json:"matched_dep"` // Which dependency matched
Reachable bool `json:"reachable"` // Is the vulnerable function called?
CallSites []CallSite `json:"call_sites,omitempty"` // Where it's called
TaintedInput bool `json:"tainted_input"` // Does user input reach it?
InputSource string `json:"input_source,omitempty"` // e.g. "HTTP POST body"
Exposed bool `json:"exposed"` // Is it on a public endpoint?
ExposurePath string `json:"exposure_path,omitempty"` // e.g. "POST /api/import"
Verdict VerdictType `json:"verdict"`
Fix string `json:"fix,omitempty"` // Remediation command
FixBreaking bool `json:"fix_breaking"` // Does the fix have breaking changes?
}
Finding represents a CVE matched against a specific project context.
type GHSAClient ¶
type GHSAClient struct {
// contains filtered or unexported fields
}
GHSAClient queries the GitHub Advisory Database. Best source for ecosystem-specific version ranges (npm, pip, Maven, etc.). Rate limits: 60/hr without token, 5000/hr with GITHUB_TOKEN.
func NewGHSAClient ¶
func NewGHSAClient(token string) *GHSAClient
func (*GHSAClient) LookupByCVE ¶
LookupByCVE searches GHSA for a specific CVE ID.
func (*GHSAClient) LookupByGHSA ¶
LookupByGHSA fetches a single GHSA advisory by its ID (e.g., "GHSA-xxxx-xxxx-xxxx").
func (*GHSAClient) QueryByPackage ¶
QueryByPackage searches GHSA for vulnerabilities in a specific package.
type KEVClient ¶
type KEVClient struct {
// contains filtered or unexported fields
}
KEVClient checks the CISA Known Exploited Vulnerabilities catalog. If a CVE is in this list, it's confirmed actively exploited in the wild.
func NewKEVClient ¶
func NewKEVClient() *KEVClient
type MatchedDep ¶
type MatchedDep struct {
Name string `json:"name"` // e.g. "lxml"
Version string `json:"version"` // e.g. "4.9.1"
Ecosystem string `json:"ecosystem"` // e.g. "PyPI"
LockFile string `json:"lock_file"` // e.g. "requirements.txt"
Transitive bool `json:"transitive"` // Is it a transitive (indirect) dependency?
Parent string `json:"parent,omitempty"` // If transitive, who depends on it?
}
MatchedDep is a dependency that matched a CVE's affected range.
type NVDClient ¶
type NVDClient struct {
// contains filtered or unexported fields
}
NVDClient queries the NVD (National Vulnerability Database) API v2.0. NVD is the authoritative source for CVSS scores and CPE matching. Rate limits: 5 req/30s without API key, 50 req/30s with API key.
func NewNVDClient ¶
func (*NVDClient) LookupByID ¶
LookupByID fetches CVE details from NVD by CVE ID.
func (*NVDClient) QueryByCPE ¶
QueryByCPE queries NVD for CVEs matching a CPE 2.3 string. Used for matching network service versions against known vulnerabilities.
type OSVClient ¶
type OSVClient struct {
// contains filtered or unexported fields
}
OSVClient queries the OSV (Open Source Vulnerabilities) database. OSV is the best source for package-level vulnerability data because it uses ecosystem-native version ranges (not CPE matching like NVD).
func NewOSVClient ¶
func NewOSVClient() *OSVClient
func (*OSVClient) LookupByID ¶
LookupByID fetches a specific vulnerability by its OSV or CVE ID.
func (*OSVClient) QueryBatch ¶
QueryBatch queries OSV for multiple packages at once (up to 1000). This is significantly faster than individual queries for large dependency lists.
type OfflineDB ¶
type OfflineDB struct {
// contains filtered or unexported fields
}
OfflineDB provides CVE lookups from a locally downloaded OSV database. This enables fully offline scanning without API calls.
func NewOfflineDB ¶
NewOfflineDB loads a previously downloaded offline database.
func (*OfflineDB) EcosystemCount ¶
EcosystemCount returns the number of loaded ecosystems.
func (*OfflineDB) LookupByID ¶
LookupByID finds a vulnerability by ID.
func (*OfflineDB) QueryPackage ¶
QueryPackage finds all CVEs affecting a specific package+version from the offline DB.
type ScanResult ¶
type ScanResult struct {
Target string `json:"target"`
ScannedAt time.Time `json:"scanned_at"`
Duration string `json:"duration"`
TotalDeps int `json:"total_deps"`
Ecosystems []string `json:"ecosystems"`
Findings []Finding `json:"findings"`
Exploitable int `json:"exploitable"`
Reachable int `json:"reachable"`
Noise int `json:"noise"`
}
ScanResult holds the complete output of a scan.
type VerdictType ¶
type VerdictType string
VerdictType classifies the exploitability of a finding.
const ( VerdictExploitable VerdictType = "EXPLOITABLE" // Reachable + tainted input + exposed VerdictReachable VerdictType = "REACHABLE" // Code calls it, but can't prove exploitability VerdictNoise VerdictType = "NOISE" // Present but not reachable )
type VersionRange ¶
type VersionRange struct {
Type string `json:"type"` // "SEMVER", "ECOSYSTEM", "GIT"
Introduced string `json:"introduced,omitempty"` // First affected version
Fixed string `json:"fixed,omitempty"` // First fixed version
LastAffected string `json:"last_affected,omitempty"`
}
VersionRange describes a range of affected versions.