Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Github ¶
type Github struct {
// contains filtered or unexported fields
}
Github is a source of vulnerabilities (https://github.com/advisories)
func (Github) CompareVulnerabilities ¶
func (g Github) CompareVulnerabilities(vulns []Vulnerability, packg Package) ([]Vulnerability, error)
CompareVulnerabilities checks if the Package version is contained in the vulns slice.
func (Github) GetVulnerabilities ¶
func (g Github) GetVulnerabilities(packg Package) ([]Vulnerability, error)
GetVulnerabilities retrieves all vulnerabilities for the given package version
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package describes a specific version of a software package
func NewPackage ¶
NewPackage creates a new Package or returns an error if it is invalid
func (*Package) IsVulnerable ¶
func (p *Package) IsVulnerable(sources []Source) ([]Vulnerability, error)
IsVulnerable checks if a package is vulnerable by checking the passed sources. If `nil` is passed as sources, Github will be used. If the package is vulnerable, then it will return a slice of Vulnerability structs.
type Semver ¶
type Semver string
Semver is a type definition for a version that follows semantic versioning
type Source ¶
type Source interface {
GetVulnerabilities(Package) ([]Vulnerability, error)
CompareVulnerabilities([]Vulnerability, Package) ([]Vulnerability, error)
}
Source is an interface that describes the source of vulnerabilities
type VersionRange ¶
type VersionRange struct {
Start Semver `json:"start"`
End Semver `json:"end"`
IncludeLeft bool `json:"left"`
IncludeRight bool `json:"right"`
}
VersionRange is used to store ranges of versions. If `start` is empty, the range will be `< end`. If `end` is empty, then it means `== start`.
func NewVersionRange ¶
func NewVersionRange(start, end Semver, left, right bool) (*VersionRange, error)
NewVersionRange creates a new [VersionRanges] and checks if it's valid
func NewVersionRangeString ¶
func NewVersionRangeString(stringRange string) (*VersionRange, error)
NewVersionRangeString creates a range given a range string (e.g. `>= v1.0`)
func (*VersionRange) Contains ¶
func (v *VersionRange) Contains(s Semver) bool
Contains checks if a Semver is contained in a VersionRange struct
func (*VersionRange) Equals ¶
func (v *VersionRange) Equals(vr VersionRange) bool
Equals checks if two VersionRange are equal (i.e. same start and end)
type Vulnerability ¶
type Vulnerability struct {
Id string `json:"id"`
Cve string `json:"cve"`
Cwes []string `json:"cwes"`
Cvss float32 `json:"cvss"`
Published time.Time `json:"published"`
RangesVulnerable []VersionRange `json:"vulnerable_ranges"`
RangesPatched []VersionRange `json:"patched_ranges"`
}
Vulnerability represents a vulnerability of a software package
func NewVulnerability ¶
func NewVulnerability(id, cve string, cwes []string, cvss float32, published string, rangesVulnerable, rangesPatched []VersionRange, timeFormat string) (*Vulnerability, error)
NewVulnerability creates a Vulnerability struct. If `timeFormat` is an empty string, then the default `2006-01-02 15:04:05 -0700` format is used.