vmaas

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OvalOperationEvrEquals   = 1
	OvalOperationEvrLessThan = 2

	OvalCheckExistenceAtLeastOne = 1
	OvalCheckExistenceNone       = 2

	OvalDefinitionTypePatch         = 1
	OvalDefinitionTypeVulnerability = 2

	OvalCriteriaOperatorAnd = 1
	OvalCriteriaOperatorOr  = 2
)
View Source
const Dump = "/data/vmaas.db"
View Source
const SecurityErrataType = "security"

Variables

View Source
var ErrProcessingInput = errors.New("processing input")

Functions

func DownloadCache

func DownloadCache(url, dest string) error

func ShouldReload added in v1.0.1

func ShouldReload(c *Cache, latestDumpEndpoint string) bool

Types

type API

type API struct {
	Cache *Cache
	// contains filtered or unexported fields
}

func InitFromFile

func InitFromFile(cachePath string, opts ...Option) (*API, error)

func InitFromURL

func InitFromURL(cacheURL string, opts ...Option) (*API, error)

func (*API) LoadCacheFromFile

func (api *API) LoadCacheFromFile(cachePath string) error

func (*API) LoadCacheFromURL

func (api *API) LoadCacheFromURL(cacheURL string) error

func (*API) PeriodicCacheReload

func (api *API) PeriodicCacheReload(interval time.Duration, latestDumpEndpoint string, cacheURL *string)

func (*API) Updates

func (api *API) Updates(request *Request) (*Updates, error)

func (*API) Vulnerabilities

func (api *API) Vulnerabilities(request *Request) (*Vulnerabilities, error)

func (*API) VulnerabilitiesExtended

func (api *API) VulnerabilitiesExtended(request *Request) (*VulnerabilitiesExtended, error)

type AffectedPackage added in v0.7.0

type AffectedPackage struct {
	Name string   `json:"package_name"`
	EVRA string   `json:"evra"`
	Cpe  CpeLabel `json:"cpe"`
}

type ArchID

type ArchID int

type CSAFCVEID added in v1.3.0

type CSAFCVEID int

type CSAFCVEProduct added in v1.3.0

type CSAFCVEProduct struct {
	ID                  CSAFCVEID
	CVEID               CVEID
	CSAFProductID       CSAFProductID
	CSAFProductStatusID int
}

type CSAFCVEs added in v1.3.0

type CSAFCVEs struct {
	Fixed   []CVEID
	Unfixed []CVEID
}

type CSAFProduct added in v1.3.0

type CSAFProduct struct {
	CpeID         CpeID
	PackageNameID NameID
	PackageID     PkgID
	ModuleStream  ModuleStream
}

type CSAFProductID added in v1.3.0

type CSAFProductID int

type CVEID added in v1.3.0

type CVEID int

type Cache

type Cache struct {
	Packagename2ID map[string]NameID
	ID2Packagename map[NameID]string

	// name -> []pkg ordered by e-v-r ordering
	Updates map[NameID][]PkgID
	// name -> evr -> idx into updates[name]
	UpdatesIndex map[NameID]map[EvrID][]int

	Evr2ID map[utils.Evr]EvrID
	ID2Evr map[EvrID]utils.Evr

	ID2Arch map[ArchID]string
	Arch2ID map[string]ArchID

	ArchCompat map[ArchID]map[ArchID]bool

	PackageDetails map[PkgID]PackageDetail
	Nevra2PkgID    map[Nevra]PkgID

	RepoIDs            []RepoID
	RepoDetails        map[RepoID]RepoDetail
	RepoLabel2IDs      map[string][]RepoID
	RepoPath2IDs       map[string][]RepoID
	Label2ContentSetID map[string]ContentSetID

	ProductID2RepoIDs map[int][]RepoID
	PkgID2RepoIDs     map[PkgID][]RepoID

	ErratumID2Name    map[ErratumID]string
	PkgID2ErrataIDs   map[PkgID][]ErratumID
	ErratumID2RepoIDs map[ErratumID]map[RepoID]bool

	CveDetail map[string]CveDetail
	CveNames  map[int]string

	PkgErratum2Module map[PkgErratum][]int
	Module2IDs        map[ModuleStream][]int
	ModuleRequires    map[int][]int
	DBChange          DBChange
	ErratumDetails    map[string]ErratumDetail
	SrcPkgID2PkgID    map[PkgID][]PkgID
	String            map[int]string

	// OVAL
	PackagenameID2definitionIDs map[NameID][]DefinitionID
	RepoID2CpeIDs               map[RepoID][]CpeID
	ContentSetID2CpeIDs         map[ContentSetID][]CpeID

	OvaldefinitionDetail            map[DefinitionID]DefinitionDetail
	OvaldefinitionID2Cves           map[DefinitionID][]string
	CpeID2OvalDefinitionIDs         map[CpeID][]DefinitionID
	OvalCriteriaID2DepModuleTestIDs map[CriteriaID][]ModuleTestID
	OvalCriteriaID2DepTestIDs       map[CriteriaID][]TestID
	OvalCriteriaID2DepCriteriaIDs   map[CriteriaID][]CriteriaID
	OvalCriteriaID2Type             map[CriteriaID]int
	OvalStateID2Arches              map[OvalStateID][]ArchID
	OvalModuleTestDetail            map[ModuleTestID]OvalModuleTestDetail
	OvalTestDetail                  map[TestID]OvalTestDetail
	OvalTestID2States               map[TestID][]OvalState
	OvalDefinitionID2ErrataIDs      map[DefinitionID][]ErratumID
	CpeID2Label                     map[CpeID]CpeLabel

	// CSAF
	CSAFProductStatus map[int]string
	CSAFCVEs          map[CSAFProduct]CSAFCVEs
}

type ContentSetID

type ContentSetID int

type CpeID

type CpeID int

type CpeLabel added in v1.4.0

type CpeLabel string

func (CpeLabel) Parse added in v1.4.0

func (l CpeLabel) Parse() (*ParsedCpe, error)

type CriteriaID

type CriteriaID int

type CveDetail

type CveDetail struct {
	RedHatURL     *string
	SecondaryURL  *string
	Cvss3Score    *string
	Cvss3Metrics  *string
	Impact        string
	PublishedDate *string
	ModifiedDate  *string
	Iava          *string
	Description   string
	Cvss2Score    *string
	Cvss2Metrics  *string
	Source        string

	CWEs      []string
	PkgIDs    []int
	ErrataIDs []int
}

type DBChange

type DBChange struct {
	ErrataChanges string `json:"errata_changes"`
	CveChanges    string `json:"cve_changes"`
	RepoChanges   string `json:"repository_changes"`
	LastChange    string `json:"last_change"`
	Exported      string `json:"exported"`
}

type DefinitionDetail

type DefinitionDetail struct {
	ID               DefinitionID
	DefinitionTypeID int
	CriteriaID       CriteriaID
}

type DefinitionID

type DefinitionID int

type ErratumDetail added in v0.7.1

type ErratumDetail struct {
	ID             ErratumID
	Synopsis       string
	Summary        *string
	Type           string
	Severity       *string
	Description    *string
	CVEs           []string
	PkgIDs         []int
	ModulePkgIDs   []int
	Bugzillas      []string
	Refs           []string
	Modules        []Module
	Solution       *string
	Issued         *string
	Updated        *string
	URL            string
	ThirdParty     bool
	RequiresReboot bool
}

type ErratumID added in v0.7.1

type ErratumID int

type EvrID

type EvrID int

type Module

type Module struct {
	Name              string
	StreamID          int
	Stream            string
	Version           string
	Context           string
	PackageList       []string
	SourcePackageList []string
}

type ModuleStream

type ModuleStream struct {
	Module string `json:"module_name"`
	Stream string `json:"module_stream"`
}

func (*ModuleStream) Scan added in v1.3.0

func (ms *ModuleStream) Scan(value interface{}) error

Implement the Scan method for the ModuleStream type

type ModuleStreamPtrs added in v0.4.3

type ModuleStreamPtrs struct {
	Module *string `json:"module_name"`
	Stream *string `json:"module_stream"`
}

type ModuleTestID

type ModuleTestID int

type NameArch

type NameArch struct {
	Name string
	Arch string
}

type NameID

type NameID int

type Nevra

type Nevra struct {
	NameID NameID
	EvrID  EvrID
	ArchID ArchID
}

type NevraIDs

type NevraIDs struct {
	NameID NameID
	EvrIDs []int
	ArchID ArchID
}

type NevraString

type NevraString struct {
	Nevra utils.Nevra
	Pkg   string
}

type Option added in v1.0.0

type Option interface {
	// contains filtered or unexported methods
}

func WithMaxGoroutines added in v1.0.0

func WithMaxGoroutines(g int) Option

Option to set maximum number of goroutines used by the lib

func WithUnfixed added in v1.0.0

func WithUnfixed(u bool) Option

Option to evaluate unfixed CVEs by OVAL

type OvalModuleTestDetail

type OvalModuleTestDetail struct {
	ModuleStream ModuleStream
}

type OvalState

type OvalState struct {
	ID           OvalStateID
	EvrID        EvrID
	OperationEvr int
}

type OvalStateID

type OvalStateID int

type OvalTestDetail

type OvalTestDetail struct {
	PkgNameID      NameID
	CheckExistence int
}

type Package added in v0.6.0

type Package struct {
	utils.Nevra
	String string
	NameID NameID
}

type PackageDetail

type PackageDetail struct {
	NameID        NameID
	EvrID         EvrID
	ArchID        ArchID
	SummaryID     int
	DescriptionID int

	SrcPkgID   *PkgID
	Modified   *time.Time
	ModifiedID int
}

type ParsedCpe added in v1.4.0

type ParsedCpe struct {
	Part     *string
	Vendor   *string
	Product  *string
	Version  *string
	Update   *string
	Edition  *string
	Language *string
}

type PkgErratum added in v0.7.1

type PkgErratum struct {
	PkgID     PkgID
	ErratumID ErratumID
}

type PkgID

type PkgID int

type ProcessedDefinition added in v0.6.0

type ProcessedDefinition struct {
	DefinitionID     DefinitionID
	DefinitionTypeID int
	CriteriaID       CriteriaID
	Packages         []Package
	Cpe              CpeLabel
}

type ProcessedDefinitions added in v0.6.0

type ProcessedDefinitions struct {
	Patch         []*ProcessedDefinition
	Vulnerability []*ProcessedDefinition
}

type ProcessedRequest

type ProcessedRequest struct {
	Updates             *Updates
	Packages            []NevraString
	Cpes                []CpeID
	NewerReleaseverCpes []CpeID
	ContentSets         []ContentSetID
	OriginalRequest     *Request
}

type ProductsPackage added in v1.4.0

type ProductsPackage struct {
	Products []CSAFProduct
	Package  Package
}

type RepoDetail

type RepoDetail struct {
	Label      string
	Name       string
	URL        string
	Basearch   string
	Releasever string
	Product    string
	ProductID  int
	Revision   *string
	LastChange *string
	ThirdParty bool
}

type RepoID

type RepoID int

type Request

type Request struct {
	Packages []string  `json:"package_list"`
	Repos    *[]string `json:"repository_list"`
	// we need to use pointers to modules to distinguish between nil and ""
	// to keep consistency with python implementation
	Modules    []ModuleStreamPtrs `json:"modules_list"`
	Releasever *string            `json:"releasever"`
	Basearch   *string            `json:"basearch"`
	RepoPaths  []string           `json:"repository_paths"`

	ThirdParty   bool `json:"third_party"`
	LatestOnly   bool `json:"latest_only"`
	SecurityOnly bool `json:"security_only"`

	Extended      bool `json:"extended"`
	EpochRequired bool `json:"epoch_required"`
	UseCsaf       bool `json:"use_csaf"`
}

type TestID

type TestID int

type Update

type Update struct {
	Package     string `json:"package"`
	PackageName string `json:"package_name"`
	EVRA        string `json:"evra"`
	Erratum     string `json:"erratum"`
	Repository  string `json:"repository"`
	Basearch    string `json:"basearch"`
	Releasever  string `json:"releasever"`
	// contains filtered or unexported fields
}

type UpdateDetail

type UpdateDetail struct {
	AvailableUpdates []Update `json:"available_updates,omitempty"`
}

type UpdateList

type UpdateList map[string]UpdateDetail

type Updates

type Updates struct {
	UpdateList UpdateList     `json:"update_list"`
	RepoList   *[]string      `json:"repository_list,omitempty"`
	RepoPaths  []string       `json:"repository_paths,omitempty"`
	ModuleList []ModuleStream `json:"modules_list,omitempty"`
	Releasever *string        `json:"releasever,omitempty"`
	Basearch   *string        `json:"basearch,omitempty"`
	LastChange time.Time      `json:"last_change"`
}

type Vulnerabilities

type Vulnerabilities struct {
	CVEs                []Vulnerability `json:"cve_list"`
	ManuallyFixableCVEs []Vulnerability `json:"manually_fixable_cve_list"`
	UnpatchedCVEs       []Vulnerability `json:"unpatched_cve_list"`
	LastChange          time.Time       `json:"last_change"`
}

type VulnerabilitiesCvesDetails

type VulnerabilitiesCvesDetails struct {
	Cves          map[string]VulnerabilityDetail
	ManualCves    map[string]VulnerabilityDetail
	UnpatchedCves map[string]VulnerabilityDetail
	LastChange    *time.Time
}

type VulnerabilitiesExtended

type VulnerabilitiesExtended struct {
	CVEs                []VulnerabilityDetail `json:"cve_list"`
	ManuallyFixableCVEs []VulnerabilityDetail `json:"manually_fixable_cve_list"`
	UnpatchedCVEs       []VulnerabilityDetail `json:"unpatched_cve_list"`
	LastChange          time.Time             `json:"last_change"`
}

type Vulnerability

type Vulnerability string

type VulnerabilityDetail

type VulnerabilityDetail struct {
	CVE      string `json:"cve"`
	Packages map[string]bool
	Errata   map[string]bool
	Affected []AffectedPackage `json:"affected,omitempty"`
}

func (VulnerabilityDetail) MarshalJSON added in v1.0.6

func (d VulnerabilityDetail) MarshalJSON() ([]byte, error)

marshal VulnerabilityDetail Packages and Errata as json arrays for backward compatibility

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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