report

package
v0.0.0-...-f404abb Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOSV     = errors.New("invalid OSV")
	ErrUnexpectedOSV  = errors.New("unexpected OSV")
	ErrNormalizing    = errors.New("normalization error")
	ErrInvalidDetails = errors.New("invalid details")
)
View Source
var ErrMergeFailure = errors.New("merge failure")

Functions

func ValidateVuln

func ValidateVuln(v *models.Vulnerability) error

ValidateVuln ensures that v conforms to the the OSV Schema, and to the specific constraints expected by the repository.

Types

type Indicators

type Indicators struct {
	Domains []string `json:"domains"`
	IPs     []string `json:"ips"`
	URLs    []string `json:"urls"`
}

func (*Indicators) UnmarshalJSON

func (i *Indicators) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmashaler interface.

The implementation ensures that the indicators-of-compromise field (iocs) is populated correctly and common problems can be detected.

type OriginRef

type OriginRef struct {
	Source       string         `json:"source"`
	SHASum       string         `json:"sha256"`
	ImportTime   time.Time      `json:"import_time"`
	ID           string         `json:"id,omitempty"`
	ModifiedTime time.Time      `json:"modified_time"`
	Ranges       []models.Range `json:"ranges,omitempty"`
	Versions     []string       `json:"versions,omitempty"`
}

type Report

type Report struct {
	Ecosystem string
	Name      string
	// contains filtered or unexported fields
}

func FromFile

func FromFile(filename string) (*Report, error)

func ReadJSON

func ReadJSON(r io.Reader) (*Report, error)

func (*Report) AddOrigin

func (r *Report) AddOrigin(sourceID, shasum string) *OriginRef

func (*Report) AliasID

func (r *Report) AliasID()

AliasID will add the ID for the report into the aliases section.

If no ID has been assigned, this function is a no-op.

func (*Report) FilterSelf

func (r *Report) FilterSelf()

FilterSelf will remove any refences to this report based on its ID from aliases or references.

If no ID has been assigned, this function is a no-op.

func (*Report) HasCommonOrigin

func (r *Report) HasCommonOrigin(other *Report) bool

func (*Report) HasOrigin

func (r *Report) HasOrigin(sourceID, shasum string) bool

func (*Report) ID

func (r *Report) ID() string

ID returns the ID for the report.

If no ID has been assigned the value will be the empty string.

func (*Report) IsWithdrawn

func (r *Report) IsWithdrawn() bool

IsWithdrawn returns whether or not the report has been withdrawn.

func (*Report) MarshalJSON

func (r *Report) MarshalJSON() ([]byte, error)

func (*Report) Merge

func (r *Report) Merge(other *Report) error

func (*Report) Normalize

func (r *Report) Normalize() error

func (*Report) ParseDetails

func (r *Report) ParseDetails() (user string, sources map[*OriginRef]string, err error)

ParseDetails attempts to separate the report details into its various parts.

If it fails to parse the details an error will be returned, and user and sources will both be empty.

On success user contains any user contributed details, and sources contains the detail provided by each unique source, where the key is the source ID.

func (*Report) Path

func (r *Report) Path() string

Path returns a directory name for where the report will be placed.

This dir must be considered unsafe and checked before usage.

func (*Report) RawDetails

func (r *Report) RawDetails() string

RawDetails returns the raw, unparsed, details of the OSV report.

func (*Report) SetDetails

func (r *Report) SetDetails(user string, sourceDetailsSet ...map[*OriginRef]string)

SetDetails constructs and stores the OSV details based on any user contributed details and any origin details for a source.

If a source has multiple origins present, the origin for the same source with the longest detail will be chosen based on the assumption that the longer detail has more information in it.

func (*Report) StripID

func (r *Report) StripID()

StripID removes the ID for the report.

func (*Report) UnmarshalJSON

func (r *Report) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmashaler interface.

The implementation ensures that the resulting parsed data is valid for the purposes of tracking malicious packages.

The implementation also extracts the database specific data tracking the origins the report.

func (*Report) WriteJSON

func (r *Report) WriteJSON(w io.Writer) error

Jump to

Keyboard shortcuts

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