osvdev

package
v0.0.0-...-097adc6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 14 Imported by: 9

Documentation

Overview

Package osvdev contains bindings to the osv.dev API

Index

Constants

View Source
const (
	QueryBatchEndpoint = "/v1/querybatch"
	QueryEndpoint      = "/v1/query"
	GetEndpoint        = "/v1/vulns"

	// DetermineVersionEndpoint is the URL for posting determineversion queries to OSV.
	DetermineVersionEndpoint = "/v1experimental/determineversion"

	// MaxQueriesPerQueryBatchRequest is a limit set in osv.dev's API, so is not configurable
	MaxQueriesPerQueryBatchRequest = 1000

	DefaultBaseURL = "https://api.osv.dev"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	MaxConcurrentBatchRequests int
	MaxRetryAttempts           int
	JitterMultiplier           float64
	BackoffDurationExponential float64
	BackoffDurationMultiplier  float64
	UserAgent                  string
}

func DefaultConfig

func DefaultConfig() ClientConfig

DefaultConfig make a default client config

type OSVClient

type OSVClient struct {
	HTTPClient  *http.Client
	Config      ClientConfig
	BaseHostURL string
}

func DefaultClient

func DefaultClient() *OSVClient

DefaultClient creates a new OSVClient with default settings

func (*OSVClient) ExperimentalDetermineVersion

func (c *OSVClient) ExperimentalDetermineVersion(ctx context.Context, query *api.DetermineVersionParameters) (*api.VersionMatchList, error)

func (*OSVClient) GetVulnByID

func (c *OSVClient) GetVulnByID(ctx context.Context, id string) (*osvschema.Vulnerability, error)

GetVulnByID is an interface to this endpoint: https://google.github.io/osv.dev/get-v1-vulns/

func (*OSVClient) Query

func (c *OSVClient) Query(ctx context.Context, query *api.Query) (*api.VulnerabilityList, error)

Query is an interface to this endpoint: https://google.github.io/osv.dev/post-v1-query/ This function performs paging invisibly until the context expires, after which all pages that has already been retrieved are returned.

See if next_page_token field in the response is fully filled out to determine if there are extra pages remaining

func (*OSVClient) QueryBatch

func (c *OSVClient) QueryBatch(ctx context.Context, queries []*api.Query) (*api.BatchVulnerabilityList, error)

QueryBatch is an interface to this endpoint: https://google.github.io/osv.dev/post-v1-querybatch/ This function performs paging invisibly until the context expires, after which all pages that has already been retrieved are returned.

See if next_page_token field in the response is fully filled out to determine if there are extra pages remaining

Jump to

Keyboard shortcuts

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