osv

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

Documentation

Overview

Package osv provides a vulnerability source backed by the OSV API.

Index

Constants

View Source
const (
	DefaultAPIURL  = "https://api.osv.dev/v1"
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Source)

Option configures a Source.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets a custom API base URL.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithUserAgent added in v0.1.2

func WithUserAgent(ua string) Option

WithUserAgent sets the User-Agent header for API requests.

type Source

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

Source implements vulns.Source using the OSV API.

func New

func New(opts ...Option) *Source

New creates a new OSV source.

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 "osv".

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 at once.

Jump to

Keyboard shortcuts

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