osvdb

package
v0.7.59-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 10 Imported by: 0

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

View Source
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.

View Source
const (
	ProblemNone    = "no OSV database could be downloaded"
	ProblemRefresh = "the last refresh of the OSV databases failed"
)

The words Problem holds.

View Source
const Host = "osv-vulnerabilities.storage.googleapis.com"

Host is where OSV's archives are downloaded from.

View Source
const MaxArchiveBytes = 2 << 30

MaxArchiveBytes bounds one archive: the largest is well under it.

Variables

View Source
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

func Dir

func Dir(home string) string

Dir is the runner home's folder of the databases.

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

func Ensure(ctx context.Context, home string, logw io.Writer) DB

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.

func (DB) Held

func (db DB) Held() bool

Held says whether this machine has an archive to scan against.

func (DB) Stale

func (db DB) Stale() []string

Stale names the archives older than StaleAfter.

Jump to

Keyboard shortcuts

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