osv

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 5 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// QueryEndpoint is the URL for posting queries to OSV.
	QueryEndpoint = "https://api.osv.dev/v1/querybatch"
	// GetEndpoint is the URL for getting vulnerabilities from OSV.
	GetEndpoint = "https://api.osv.dev/v1/vulns"
	// DetermineVersionEndpoint is the URL for posting determineversion queries to OSV.
	DetermineVersionEndpoint = "https://api.osv.dev/v1experimental/determineversion"
	// BaseVulnerabilityURL is the base URL for detailed vulnerability views.
	BaseVulnerabilityURL = "https://osv.dev/"
)

Variables

View Source
var RequestUserAgent = ""

Functions

func Get

func Get(id string) (*models.Vulnerability, error)

Get a Vulnerability for the given ID.

func GetWithClient added in v1.3.3

func GetWithClient(id string, client *http.Client) (*models.Vulnerability, error)

GetWithClient gets a Vulnerability for the given ID with the provided http client.

Types

type BatchedQuery

type BatchedQuery struct {
	Queries []*Query `json:"queries"`
}

BatchedQuery represents a batched query to OSV.

type BatchedResponse

type BatchedResponse struct {
	Results []MinimalResponse `json:"results"`
}

BatchedResponse represents an unhydrated batched response from OSV.

func MakeRequest

func MakeRequest(request BatchedQuery) (*BatchedResponse, error)

MakeRequest sends a batched query to osv.dev

func MakeRequestWithClient added in v1.3.3

func MakeRequestWithClient(request BatchedQuery, client *http.Client) (*BatchedResponse, error)

MakeRequestWithClient sends a batched query to osv.dev with the provided http client.

type DetermineVersionHash added in v1.4.3

type DetermineVersionHash struct {
	Path string `json:"path"`
	Hash []byte `json:"hash"`
}

DetermineVersionHash holds the per file hash and path information for determineversion.

type DetermineVersionResponse added in v1.4.3

type DetermineVersionResponse struct {
	Matches []struct {
		Score    float64 `json:"score"`
		RepoInfo struct {
			Type    string `json:"type"`
			Address string `json:"address"`
			Tag     string `json:"tag"`
			Version string `json:"version"`
			Commit  string `json:"commit"`
		} `json:"repo_info"`
	} `json:"matches"`
}

func MakeDetermineVersionRequest added in v1.4.3

func MakeDetermineVersionRequest(name string, hashes []DetermineVersionHash) (*DetermineVersionResponse, error)

type HydratedBatchedResponse

type HydratedBatchedResponse struct {
	Results []Response `json:"results"`
}

HydratedBatchedResponse represents a hydrated batched response from OSV.

func Hydrate

Hydrate fills the results of the batched response with the full Vulnerability details.

func HydrateWithClient added in v1.3.3

func HydrateWithClient(resp *BatchedResponse, client *http.Client) (*HydratedBatchedResponse, error)

HydrateWithClient fills the results of the batched response with the full Vulnerability details using the provided http client.

type MinimalResponse

type MinimalResponse struct {
	Vulns []MinimalVulnerability `json:"vulns"`
}

MinimalResponse represents an unhydrated response from OSV.

type MinimalVulnerability

type MinimalVulnerability struct {
	ID string `json:"id"`
}

MinimalVulnerability represents an unhydrated vulnerability entry from OSV.

type Package

type Package struct {
	PURL      string `json:"purl,omitempty"`
	Name      string `json:"name,omitempty"`
	Ecosystem string `json:"ecosystem,omitempty"`
}

Package represents a package identifier for OSV.

type Query

type Query struct {
	Commit   string            `json:"commit,omitempty"`
	Package  Package           `json:"package,omitempty"`
	Version  string            `json:"version,omitempty"`
	Source   models.SourceInfo `json:"-"` // TODO: Move this into Info struct in v2
	Metadata models.Metadata   `json:"-"`
}

Query represents a query to OSV.

func MakeCommitRequest

func MakeCommitRequest(commit string) *Query

MakeCommitRequest makes a commit hash request.

func MakePURLRequest

func MakePURLRequest(purl string) *Query

MakePURLRequest makes a PURL request.

func MakePkgRequest

func MakePkgRequest(pkgDetails lockfile.PackageDetails) *Query

type Response

type Response struct {
	Vulns []models.Vulnerability `json:"vulns"`
}

Response represents a full response from OSV.

Jump to

Keyboard shortcuts

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