Documentation ¶
Index ¶
- Variables
- type APIDB
- type Affected
- type Affects
- type AffectsRange
- type AffectsRangeType
- type Cache
- type Config
- type DB
- type DirDB
- func (db *DirDB) Check(pkgs []internal.PackageDetails) ([]Vulnerabilities, error)
- func (db *DirDB) Identifier() string
- func (db *DirDB) Name() string
- func (db *DirDB) Vulnerabilities(includeWithdrawn bool) []OSV
- func (db *DirDB) VulnerabilitiesAffectingPackage(pkg internal.PackageDetails) Vulnerabilities
- type Ecosystem
- type OSV
- type ObjectWithID
- type Package
- type RangeEvent
- type Reference
- type Versions
- type Vulnerabilities
- type ZipDB
- func (db *ZipDB) Check(pkgs []internal.PackageDetails) ([]Vulnerabilities, error)
- func (db *ZipDB) Identifier() string
- func (db *ZipDB) Name() string
- func (db *ZipDB) Vulnerabilities(includeWithdrawn bool) []OSV
- func (db *ZipDB) VulnerabilitiesAffectingPackage(pkg internal.PackageDetails) Vulnerabilities
Constants ¶
This section is empty.
Variables ¶
var ErrAPICouldNotMarshalPayload = errors.New("could not marshal payload")
var ErrAPIRequestFailed = errors.New("api request failed")
var ErrAPIRequestInvalid = errors.New("api request invalid")
var ErrAPIResponseNotJSON = errors.New("api response could not be parsed as json")
var ErrAPIResultsCountMismatch = errors.New("api results count mismatch")
var ErrAPIUnexpectedResponse = errors.New("api returned unexpected status")
var ErrAPIUnreadableResponse = errors.New("could not read response body")
var ErrDirPathWrongProtocol = errors.New("directory path must start with \"file:\" protocol")
var ErrInvalidBatchSize = errors.New("batch size must be greater than 0")
var ErrOfflineDatabaseNotFound = errors.New("no offline version of the OSV database is available")
var ErrOfflineDatabaseNotSupported = errors.New("API database does not support being used offline")
var ErrUnexpectedStatusCode = errors.New("db host returned an unexpected status code")
var ErrUnsupportedDatabaseType = errors.New("unsupported database source type")
Functions ¶
This section is empty.
Types ¶
type APIDB ¶
func (APIDB) Check ¶
func (db APIDB) Check(pkgs []internal.PackageDetails) ([]Vulnerabilities, error)
func (APIDB) FetchAll ¶
func (db APIDB) FetchAll(ids []string) Vulnerabilities
func (APIDB) Identifier ¶
type Affects ¶
type Affects []AffectsRange
type AffectsRange ¶
type AffectsRange struct { Type AffectsRangeType `json:"type"` Events []RangeEvent `json:"events"` }
type AffectsRangeType ¶
type AffectsRangeType string
const ( TypeSemver AffectsRangeType = "SEMVER" TypeEcosystem AffectsRangeType = "ECOSYSTEM" TypeGit AffectsRangeType = "GIT" )
type Cache ¶
type Cache struct { URL string `json:"url"` ETag string `json:"etag"` Date string `json:"date"` Body []byte `json:"body"` }
Cache stores the OSV database archive for re-use
type Config ¶
type Config struct { Name string `yaml:"name"` Type string `yaml:"type"` URL string `yaml:"url"` WorkingDirectory string `yaml:"working-directory"` }
func (Config) Identifier ¶
Identifier returns a unique string that can be used to check if a loaded database has been configured with this Config
type DB ¶
type DB interface { Name() string // Identifier can be used to check what config this database represents Identifier() string // Check looks for known vulnerabilities for the given pkgs within this OSV database. // // The vulnerabilities are returned in an array whose index align with the index of // the package that they're for within the pkgs array that was given. Check(pkgs []internal.PackageDetails) ([]Vulnerabilities, error) }
type DirDB ¶
type DirDB struct { LocalPath string WorkingDirectory string Offline bool // contains filtered or unexported fields }
func (*DirDB) Check ¶
func (db *DirDB) Check(pkgs []internal.PackageDetails) ([]Vulnerabilities, error)
func (*DirDB) Identifier ¶
func (*DirDB) Vulnerabilities ¶
func (*DirDB) VulnerabilitiesAffectingPackage ¶
func (db *DirDB) VulnerabilitiesAffectingPackage(pkg internal.PackageDetails) Vulnerabilities
type OSV ¶
type OSV struct { ID string `json:"id"` Aliases []string `json:"aliases"` Summary string `json:"summary"` Published time.Time `json:"published"` Modified time.Time `json:"modified"` Withdrawn *time.Time `json:"withdrawn,omitempty"` Details string `json:"details"` Affected []Affected `json:"affected"` }
OSV represents an OSV style JSON vulnerability database entry
func (*OSV) IsAffected ¶
func (osv *OSV) IsAffected(pkg internal.PackageDetails) bool
type ObjectWithID ¶
type ObjectWithID struct {
ID string `json:"id"`
}
type Package ¶
func (Package) NormalizedName ¶
NormalizedName ensures that the package name is normalized based on ecosystem in accordance to the OSV specification.
This is required because currently both GitHub and Pip seem to be a bit inconsistent in their package name handling, so we normalize them to be on the safe side.
In the future, it's hoped that this can be improved.
type RangeEvent ¶
type Versions ¶
type Versions []string
func (Versions) MarshalJSON ¶
MarshalJSON ensures that if there are no versions, an empty array is used as the value instead of "null"
type Vulnerabilities ¶
type Vulnerabilities []OSV
func (Vulnerabilities) Includes ¶
func (vs Vulnerabilities) Includes(vulnerability OSV) bool
func (Vulnerabilities) MarshalJSON ¶
func (vs Vulnerabilities) MarshalJSON() ([]byte, error)
MarshalJSON ensures that if there are no vulnerabilities, an empty array is used as the value instead of "null"
func (Vulnerabilities) Unique ¶
func (vs Vulnerabilities) Unique() Vulnerabilities
type ZipDB ¶
type ZipDB struct { ArchiveURL string WorkingDirectory string Offline bool UpdatedAt string // contains filtered or unexported fields }
func (*ZipDB) Check ¶
func (db *ZipDB) Check(pkgs []internal.PackageDetails) ([]Vulnerabilities, error)
func (*ZipDB) Identifier ¶
func (*ZipDB) Vulnerabilities ¶
func (*ZipDB) VulnerabilitiesAffectingPackage ¶
func (db *ZipDB) VulnerabilitiesAffectingPackage(pkg internal.PackageDetails) Vulnerabilities