db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	SaveScanVulnerabilities(scanID string, date string, reports []report.Report) error
	GetScanVulnerabilities(scanID ...string) ([]models.Vulnerability, error)
	GetTargetVulnerabilities(target ...string) ([]models.Vulnerability, error)
}

DB defines the methods for the persistence layer to be implemented.

type MemDB

type MemDB struct {
	// Historic is a map that stores the reports generated by the
	// execution of every Check.
	// The map key is a MD5 sum of the concatenation of the following fields:
	// - Name of the Checktype for the executed Check
	// - Target of the executed Check
	// - Options of the executed Check
	// Those three fields together conform the PRIMARY KEY.
	// The value of map entries is an array of struct containing:
	// - The scanID the Check pertains to
	// - The date of the scan when the Check was executed
	// - The Vulcan Core Report associated to it.
	// The array is ordered by execution time, so last entry overwrites previous one.
	Historic map[string][]entry
	// contains filtered or unexported fields
}

MemDB is a concurrent-safe persistence layer stored in memory. It stores both the vulnerabilities detected for every scan.

func LoadState

func LoadState(stateFile string) (*MemDB, error)

LoadState retrieves current state of the DB from a file.

func NewMemDB

func NewMemDB() *MemDB

NewMemDB creates a new MemDB instance and returns its address.

func (*MemDB) GetScanVulnerabilities

func (m *MemDB) GetScanVulnerabilities(scanID ...string) ([]models.Vulnerability, error)

GetScanVulnerabilities retrieves the vulnerabilities of the given scans from the storage.

func (*MemDB) GetTargetVulnerabilities

func (m *MemDB) GetTargetVulnerabilities(target ...string) ([]models.Vulnerability, error)

GetTargetVulnerabilities retrieves the vulnerabilities of the given targets from the storage.

func (*MemDB) SaveScanVulnerabilities

func (m *MemDB) SaveScanVulnerabilities(scanID string, date string, reports []report.Report) error

SaveScanVulnerabilities gets a list of Vulcan Core Reports and updates the historic.

func (*MemDB) SaveState

func (m *MemDB) SaveState(stateFile string) error

SaveState stores the current state of the DB in a file.

Jump to

Keyboard shortcuts

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