grypedb

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: 14 Imported by: 0

Documentation

Overview

Package grypedb provides a vulnerability source backed by the Grype vulnerability database. The database is a SQLite file that can be downloaded from Anchore's CDN or used locally.

Index

Constants

View Source
const (
	// LatestDBURL is the URL to fetch the latest database listing
	LatestDBURL = "https://grype.anchore.io/databases/v6/listing.json"

	DefaultTimeout = 60 * time.Second
)

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, destDir string) (string, error)

Download downloads the latest Grype database to the specified directory. Returns the path to the downloaded database file.

Types

type Option

type Option func(*Source)

Option configures a Source.

func WithAutoDownload

func WithAutoDownload() Option

WithAutoDownload enables automatic downloading of the database if missing.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets a custom HTTP client for downloading the database.

type Source

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

Source implements vulns.Source using a local Grype database.

func New

func New(dbPath string, opts ...Option) (*Source, error)

New creates a new Grype database source. If dbPath points to a directory, it looks for vulnerability.db inside it. If dbPath points to a file, it uses that file directly. With WithAutoDownload(), downloads the database if missing.

func (*Source) Close

func (s *Source) Close() error

Close closes the database connection.

func (*Source) Get

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

Get fetches a specific vulnerability by ID.

func (*Source) Name

func (s *Source) Name() string

Name returns "grype".

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.

func (*Source) QueryBatch

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

QueryBatch queries multiple packages.

Jump to

Keyboard shortcuts

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