Documentation
¶
Overview ¶
Package osvdb keeps this machine's copy of OSV's vulnerability databases, which the Coding agent's dependency scan reads offline. OSV publishes one archive per ecosystem, refreshed daily, at its public bucket. Ensure downloads each archive the runner wants into the runner home, in the layout OSV-Scanner reads (osv-scalibr/<ecosystem>/all.zip), when it was last fetched over a day ago, replacing a file only once a new one is whole. The download is the CLI's own: no container and no project file is involved, and the scan that reads the copy runs with no access to OSV at all. A refresh that fails keeps the copy it has; with none, the scan says there is no database rather than finding nothing.
Index ¶
Constants ¶
const ( RefreshAfter = 24 * time.Hour RetryAfter = time.Hour StaleAfter = 7 * 24 * time.Hour )
The ages of a copy: asked again after a day, a failed refresh not tried again for an hour, and older than a week named stale.
const ( ProblemNone = "no OSV database could be downloaded" ProblemRefresh = "the last refresh of the OSV databases failed" )
The words Problem holds.
const Host = "osv-vulnerabilities.storage.googleapis.com"
Host is where OSV's archives are downloaded from.
const MaxArchiveBytes = 2 << 30
MaxArchiveBytes bounds one archive: the largest is well under it.
Variables ¶
var Ecosystems = []string{"Go", "npm", "PyPI", "crates.io", "Maven", "RubyGems", "Packagist", "NuGet"}
Ecosystems are the archives fetched: the ecosystems of the lockfiles the Coding agent's toolchains write.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// Dir holds osv-scalibr/<ecosystem>/all.zip; empty when this machine
// has no archive at all.
Dir string
// Fetched is when each archive held was last downloaded whole.
Fetched map[string]time.Time
// Problem says why there is no copy, or that the last refresh failed.
Problem string
}
DB is the copy a scan mounts.
func Ensure ¶
Ensure answers the copy for a scan, refreshing it first when it is due. It never fails: a refresh's error is logged and named in Problem, and the archives this machine has are answered.