ossindex

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

README

ossindex-client

CI PkgGoDev License

Unofficial Go client for Sonatype OSS Index

Installation

GO111MODULE=on go get github.com/nscuro/ossindex-client

Compatibility

Go OSS Index REST API
1.15+ v3

Usage

See examples.

Documentation

Index

Constants

View Source
const (
	DefaultTimeout   = 10 * time.Second
	DefaultUserAgent = "github.com/nscuro/ossindex-client"
)
View Source
const MaxCoordinatesCount = 128

MaxCoordinatesCount describes the maximum allowed amount of coordinates per request.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int    `json:"code"`
	Message    string `json:"message"`
}

func (APIError) Error

func (e APIError) Error() string

type Client

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

func NewClient

func NewClient(options ...ClientOption) (*Client, error)

NewClient creates a new client, optionally applying

func (Client) GetComponentReports

func (c Client) GetComponentReports(ctx context.Context, coordinates []string) ([]ComponentReport, error)

GetComponentReports requests vulnerability reports for one or more components.

OSS Index enforces a limit of 128 coordinates per request. If the given coordinates slice exceeds this limit, Client will chunk them and perform multiple requests.

type ClientOption

type ClientOption func(*Client) error

func WithAuthentication

func WithAuthentication(username, token string) ClientOption

WithAuthentication enables authentication using the given credentials.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout overrides the default timeout.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent overrides the default user agent.

type ComponentReport

type ComponentReport struct {
	Coordinates     string          `json:"coordinates"`
	Description     string          `json:"description"`
	Reference       string          `json:"reference"`
	Vulnerabilities []Vulnerability `json:"vulnerabilities"`
}

type Vulnerability

type Vulnerability struct {
	ID            string   `json:"id"`
	DisplayName   string   `json:"displayName"`
	Title         string   `json:"title"`
	Description   string   `json:"description"`
	CVSSScore     float64  `json:"cvssScore"`
	CVSSVector    string   `json:"cvssVector"`
	CWE           string   `json:"cwe"`
	CVE           string   `json:"cve"`
	Reference     string   `json:"reference"`
	VersionRanges []string `json:"versionRange"`
}

Directories

Path Synopsis
examples
example command

Jump to

Keyboard shortcuts

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