db

package
v0.0.0-...-c97ac92 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddAssetDepInput

type AddAssetDepInput struct {
	ID string `json:"id"`
}

type AddAssetInput

type AddAssetInput struct {
	ID           string             `json:"id"`
	Name         string             `json:"name"`
	CPE23        string             `json:"cpe23"`
	Dependents   []AddAssetDepInput `json:"dependents"`
	Dependencies []AddAssetDepInput `json:"dependencies"`
}

type AddCVEInput

type AddCVEInput struct {
	ID              string                 `json:"id"`
	Description     string                 `json:"description"`
	PublicationDate time.Time              `json:"publicationDate"`
	LastUpdate      time.Time              `json:"lastUpdate"`
	CVSS2Vector     *string                `json:"cvss2Vector,omitempty"`
	CVSS3Vector     *string                `json:"cvss3Vector,omitempty"`
	Configurations  []AddCVENodeInput      `json:"configurations"`
	References      []AddCVEReferenceInput `json:"references"`
}

type AddCVENodeCPEMatchInput

type AddCVENodeCPEMatchInput struct {
	Vulnerable            bool    `json:"vulnerable"`
	CPE23                 string  `json:"cpe23"`
	VersionStartIncluding *string `json:"versionStartIncluding,omitempty"`
	VersionStartExcluding *string `json:"versionStartExcluding,omitempty"`
	VersionEndIncluding   *string `json:"versionEndIncluding,omitempty"`
	VersionEndExcluding   *string `json:"versionEndExcluding,omitempty"`
}

type AddCVENodeInput

type AddCVENodeInput struct {
	Negate     *bool                     `json:"negate,omitempty"`
	Operator   string                    `json:"operator"`
	Children   []AddCVENodeInput         `json:"children"`
	CPEMatches []AddCVENodeCPEMatchInput `json:"cpeMatches"`
}

type AddCVEReferenceInput

type AddCVEReferenceInput struct {
	URL       string   `json:"url"`
	Name      string   `json:"name"`
	Refsource string   `json:"refsource"`
	Tags      []string `json:"tags"`
}

type DeleteAssetInput

type DeleteAssetInput struct {
	ID string `json:"id"`
}

type DeleteCVEInput

type DeleteCVEInput struct {
	ID string `json:"id"`
}

type ErrAlreadyExist

type ErrAlreadyExist struct {
	K Key
	V string
}

ErrAlreadyExist is returned when the in-memory DB already know an element of value V for the type given its key.

func (ErrAlreadyExist) Error

func (err ErrAlreadyExist) Error() string

type ErrNotExist

type ErrNotExist struct {
	K Key
	V string
}

ErrNotExist is returned when the in-memory DB does not know an element of value V for the type given its key.

func (ErrNotExist) Error

func (err ErrNotExist) Error() string

type GetAssetInput

type GetAssetInput struct {
	ID string `json:"id"`
}

type GetCVEInput

type GetCVEInput struct {
	ID string `json:"id"`
}

type Key

type Key string
var (
	KeyCVE   Key = "cve"
	KeyAsset Key = "asset"
)

type Memory

type Memory struct {

	// Assets indexes *model.Asset on to the ID
	Assets map[string]*model.Asset
	// AssetVPIndex indexes *model.Asset on the vendor:product
	// couple of the CPEs.
	// Second map indexes by the Asset's ID.
	AssetVPIndex map[string]map[string]struct{}

	// CVEs indexes *model.CVE on to the ID
	CVEs map[string]*model.CVE
	// CVEVPIndex indexes *model.CVE on the vendor:product couple
	// of the CPEs in its configurations.
	// Second map indexes by the CVE's ID.
	CVEVPIndex map[string]map[string]struct{}
	// contains filtered or unexported fields
}

Memory holds the in-memory graph database, powering the whole tool. It only achieve what a standard graph database is expected to do : checks for consistency of (un)existing objects, but no more. Cycles, multigraphs...etc. are handled by the business layer.

Input and output objects are hardened by a copy of values to block the possibility of modifying the outside data affecting the saved data, so a Memory instance can behave as an outside component (sealed from the current application).

func NewMemory

func NewMemory() *Memory

func (*Memory) AddAsset

func (mem *Memory) AddAsset(input AddAssetInput) error

func (*Memory) AddCVE

func (mem *Memory) AddCVE(input AddCVEInput) error

func (*Memory) DeleteAsset

func (mem *Memory) DeleteAsset(input DeleteAssetInput) error

func (*Memory) DeleteCVE

func (mem *Memory) DeleteCVE(input DeleteCVEInput) error

func (*Memory) GetAsset

func (mem *Memory) GetAsset(input GetAssetInput) (*model.Asset, error)

func (*Memory) GetAssetCVEs

func (mem *Memory) GetAssetCVEs(asset *model.Asset) []*model.CVE

GetAssetCVEs returns a Asset's CVEs. As it is an edge resolver, it does not perform a check on the given pointer.

func (*Memory) GetCVE

func (mem *Memory) GetCVE(input GetCVEInput) (*model.CVE, error)

func (*Memory) GetCVEAssets

func (mem *Memory) GetCVEAssets(cve *model.CVE) []*model.Asset

GetCVEAssets returns a CVE's Assets. As it is an edge resolver, it does not perform a check on the id.

func (*Memory) QueryAssets

func (mem *Memory) QueryAssets(input QueryAssetInput) []*model.Asset

func (*Memory) QueryCVEs

func (mem *Memory) QueryCVEs(input QueryCVEInput) []*model.CVE

func (*Memory) UpdateAsset

func (mem *Memory) UpdateAsset(input UpdateAssetInput) error

func (*Memory) UpdateCVE

func (mem *Memory) UpdateCVE(input UpdateCVEInput) error

type QueryAssetInput

type QueryAssetInput struct {
	VP *string `json:"vp,omitempty"`
}

type QueryCVEInput

type QueryCVEInput struct {
	VP *string `json:"vp,omitempty"`
}

type UpdateAssetCVEsInput

type UpdateAssetCVEsInput struct {
	ID string `json:"id"`
}

type UpdateAssetDepInput

type UpdateAssetDepInput struct {
	ID string `json:"id"`
}

type UpdateAssetInput

type UpdateAssetInput struct {
	ID           string                 `json:"id"`
	Name         *string                `json:"name,omitempty"`
	CPE23        *string                `json:"cpe23,omitempty"`
	Dependents   []UpdateAssetDepInput  `json:"dependents,omitempty"`
	Dependencies []UpdateAssetDepInput  `json:"dependencies,omitempty"`
	CVEs         []UpdateAssetCVEsInput `json:"cves,omitempty"`
}

type UpdateCVEAssetInput

type UpdateCVEAssetInput struct {
	ID string `json:"id"`
}

type UpdateCVEInput

type UpdateCVEInput struct {
	ID             string                     `json:"id"`
	Description    *string                    `json:"description,omitempty"`
	LastUpdate     *time.Time                 `json:"lastUpdate"`
	CVSS2Vector    *string                    `json:"cvss2Vector,omitempty"`
	CVSS3Vector    *string                    `json:"cvss3Vector,omitempty"`
	Configurations []UpdateCVENodeInput       `json:"configurations"`
	Assets         []UpdateCVEAssetInput      `json:"assets"`
	References     []UpdateCVEReferencesInput `json:"references"`
}

type UpdateCVENodeCPEMatchInput

type UpdateCVENodeCPEMatchInput struct {
	Vulnerable            bool    `json:"vulnerable"`
	CPE23                 string  `json:"cpe23"`
	VersionStartIncluding *string `json:"versionStartIncluding,omitempty"`
	VersionStartExcluding *string `json:"versionStartExcluding,omitempty"`
	VersionEndIncluding   *string `json:"versionEndIncluding,omitempty"`
	VersionEndExcluding   *string `json:"versionEndExcluding,omitempty"`
}

type UpdateCVENodeInput

type UpdateCVENodeInput struct {
	Negate     *bool                        `json:"negate,omitempty"`
	Operator   string                       `json:"operator"`
	Children   []UpdateCVENodeInput         `json:"children"`
	CPEMatches []UpdateCVENodeCPEMatchInput `json:"cpeMatches"`
}

type UpdateCVEReferencesInput

type UpdateCVEReferencesInput struct {
	URL       string   `json:"url"`
	Name      string   `json:"name"`
	Refsource string   `json:"refsource"`
	Tags      []string `json:"tags"`
}

Jump to

Keyboard shortcuts

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