client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package client provides an interface for accessing vulnerability databases, via either HTTP or local filesystem access.

The protocol is described at https://go.dev/security/vuln/database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// ByModule returns the entries that affect the given module path.
	// It returns (nil, nil) if there are none.
	ByModule(context.Context, string) ([]*osv.Entry, error)

	// LastModifiedTime returns the time that the database was last modified.
	// It can be used by tools that periodically check for vulnerabilities
	// to avoid repeating work.
	LastModifiedTime(context.Context) (time.Time, error)
}

Client interface for fetching vulnerabilities based on module path or ID.

func NewClient

func NewClient(source string, opts *Options) (_ Client, err error)

NewClient returns a client that reads the vulnerability database in source (an "http" or "file" prefixed URL).

It currently supports database sources in both the v1 and legacy formats, preferring the v1 format if both are implemented. Support for the legacy database format will be removed soon.

func NewInMemoryClient

func NewInMemoryClient(entries []*osv.Entry) (Client, error)

func NewLegacyClient

func NewLegacyClient(source string, opts *Options) (_ Client, err error)

func NewV1Client

func NewV1Client(source string, opts *Options) (_ Client, err error)

type Options

type Options struct {
	HTTPClient *http.Client
}

Jump to

Keyboard shortcuts

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