match

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ApplyIgnoreRules added in v0.21.1

func ApplyIgnoreRules(matches Matches, rules []IgnoreRule) (Matches, []IgnoredMatch)

ApplyIgnoreRules iterates through the provided matches and, for each match, determines if the match should be ignored, by evaluating if any of the provided IgnoreRules apply to the match. If any rules apply to the match, all applicable rules are attached to the Match to form an IgnoredMatch. ApplyIgnoreRules returns two collections: the matches that are not being ignored, and the matches that are being ignored.

Types

type ByElements added in v0.13.0

type ByElements []Match

func (ByElements) Len added in v0.13.0

func (m ByElements) Len() int

Len is the number of elements in the collection.

func (ByElements) Less added in v0.13.0

func (m ByElements) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (ByElements) Swap added in v0.13.0

func (m ByElements) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type Details added in v0.13.0

type Details struct {
	SearchedBy interface{} // The specific attributes that were used to search (other than package name and version) --this indicates "how" the match was made.
	Found      interface{} // The specific attributes on the vulnerability object that were matched with --this indicates "what" was matched on / within.
	Matcher    MatcherType // The matcher object that discovered the match.
	Confidence float64     // The certainty of the match as a ratio (currently unused, reserved for future use).
}

type Fingerprint added in v0.13.0

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

type IgnoreRule added in v0.21.1

type IgnoreRule struct {
	Vulnerability string            `yaml:"vulnerability" json:"vulnerability" mapstructure:"vulnerability"`
	FixState      string            `yaml:"fix-state" json:"fix-state" mapstructure:"fix-state"`
	Package       IgnoreRulePackage `yaml:"package" json:"package" mapstructure:"package"`
}

An IgnoreRule specifies criteria for a vulnerability match to meet in order to be ignored. Not all criteria (fields) need to be specified, but all specified criteria must be met by the vulnerability match in order for the rule to apply.

type IgnoreRulePackage added in v0.21.1

type IgnoreRulePackage struct {
	Name     string `yaml:"name" json:"name" mapstructure:"name"`
	Version  string `yaml:"version" json:"version" mapstructure:"version"`
	Type     string `yaml:"type" json:"type" mapstructure:"type"`
	Location string `yaml:"location" json:"location" mapstructure:"location"`
}

IgnoreRulePackage describes the Package-specific fields that comprise the IgnoreRule.

type IgnoredMatch added in v0.21.1

type IgnoredMatch struct {
	Match

	// AppliedIgnoreRules are the rules that were applied to the match that caused Grype to ignore it.
	AppliedIgnoreRules []IgnoreRule
}

An IgnoredMatch is a vulnerability Match that has been ignored because one or more IgnoreRules applied to the match.

type Match

type Match struct {
	Type          Type                        // The kind of match made (an exact match, fuzzy match, indirect vs direct, etc).
	Vulnerability vulnerability.Vulnerability // The vulnerability details of the match.
	Package       pkg.Package                 // The package used to search for a match.
	MatchDetails  []Details                   // all ways in which how this particular match was made.
}

Match represents a finding in the vulnerability matching process, pairing a single package and a single vulnerability object.

func (Match) Fingerprint added in v0.13.0

func (m Match) Fingerprint() Fingerprint

func (Match) String

func (m Match) String() string

String is the string representation of select match fields.

func (Match) Summary

func (m Match) Summary() string

type MatcherType

type MatcherType int
const (
	UnknownMatcherType MatcherType = iota
	StockMatcher
	ApkMatcher
	RubyGemMatcher
	DpkgMatcher
	RpmDBMatcher
	JavaMatcher
	PythonMatcher
	JavascriptMatcher
	MsrcMatcher
)

func (MatcherType) String

func (f MatcherType) String() string

type Matches

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

func NewMatches

func NewMatches() Matches

func (*Matches) Add

func (r *Matches) Add(p pkg.Package, matches ...Match)

func (*Matches) Count

func (r *Matches) Count() int

Count returns the total number of matches in a result

func (*Matches) Enumerate

func (r *Matches) Enumerate() <-chan Match

func (*Matches) GetByPkgID

func (r *Matches) GetByPkgID(id pkg.ID) []Match

GetByPkgID returns a slice of potential matches from an ID

func (*Matches) Merge

func (r *Matches) Merge(other Matches)

func (*Matches) Sorted added in v0.12.1

func (r *Matches) Sorted() []Match

type Type

type Type int
const (
	UnknownMatchType Type = iota
	ExactDirectMatch
	ExactIndirectMatch
	FuzzyMatch
)

func ParseType

func ParseType(userStr string) Type

func (Type) String

func (f Type) String() string

Jump to

Keyboard shortcuts

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