dao

package
v0.0.0-...-93c0e2b Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(dsn string) (*gorm.DB, error)

Connect to a postgres database

func VulnerabilityToClair

func VulnerabilityToClair(v *Vulnerability) *claircore.Vulnerability

VulnerabilityToClair vulnerabity db record to clair form

func X

func X(ctx context.Context, db *sqlx.DB, fn func(tx *sqlx.Tx) error, opts ...*sql.TxOptions) error

X start transaction

Types

type PackageRepo

type PackageRepo interface {
	AmendPackageIDs(context.Context, []*claircore.Package) error
}

PackageRepo deal with package

func NewPackageRepo

func NewPackageRepo(db *gorm.DB) PackageRepo

NewPackageRepo new package repo

type UpdateOperation

type UpdateOperation struct {
	ID int64

	driver.UpdateOperation `gorm:"embedded"`
}

UpdateOperation db dao

type UpdaterRepo

type UpdaterRepo interface {
	GetLastUpdateOperation(ctx context.Context) (*driver.UpdateOperation, error)
	CountVulnerability(ctx context.Context, since time.Time) (updateOpNum int64, vulNum int64, err error)
	ListUpdateOperations(ctx context.Context, since time.Time) ([]*UpdateOperation, error)
	ListVulnerabilities(ctx context.Context, opID int64) ([]*claircore.Vulnerability, error)
}

UpdaterRepo deal with updates

func NewUpdaterRepo

func NewUpdaterRepo(db *gorm.DB) UpdaterRepo

NewUpdaterRepo updater repo

type VulDist

type VulDist struct {
	// unique ID of this distribution. this will be created as discovered by the library
	// and used for persistence and hash map indexes.
	ID string
	// A string identifying the operating system.
	// example: "Ubuntu"
	Name string
	// A string identifying the operating system version, excluding any OS name information,
	// possibly including a release code name, and suitable for presentation to the user.
	// example: "16.04.6 LTS (Xenial Xerus)"
	Version string

	// A lower-case string (mostly numeric, no spaces or other characters outside of 0–9, a–z, ".", "_" and "-")
	// identifying the operating system version, excluding any OS name information or release code name,
	// example: "16.04"
	VersionID string
	// A lower-case string (no spaces or other characters outside of 0–9, a–z, ".", "_" and "-") identifying the operating system release code name,
	// excluding any OS name information or release version, and suitable for processing by scripts or usage in generated filenames
	// example: "xenial"
	VersionCodeName string

	// A string identifying the OS architecture
	// example: "x86_64"
	Arch string
	// Optional common platform enumeration identifier
	CPE cpe.WFN
	// A pretty operating system name in a format suitable for presentation to the user.
	// May or may not contain a release code name or OS version of some kind, as suitable. If not set, defaults to "PRETTY_NAME="Linux"".
	// example: "PRETTY_NAME="Fedora 17 (Beefy Miracle)"".
	PrettyName string
}

VulDist dist_* fields in table vuln

type VulPackage

type VulPackage struct {
	// the name of the package
	Name string `gorm:"name"`
	// the version of the package
	Version string
	// type of package. currently expectations are binary or source
	Kind string
	// Module and stream which this package is part of
	Module string
	// Package architecture
	Arch string
}

VulPackage represent related package_* fields in table vuln

type VulRepository

type VulRepository struct {
	Name string
	Key  string
	URI  string
}

VulRepository is a package repository

type Vulnerability

type Vulnerability struct {
	// unique ID of this vulnerability. this will be created as discovered by the library
	// and used for persistence and hash map indexes
	ID string
	// the updater that discovered this vulnerability
	Updater string
	// the name of the vulnerability. for example if the vulnerability exists in a CVE database this
	// would the unique CVE name such as CVE-2017-11722
	Name string
	// the description of the vulnerability
	Description string
	// the timestamp when vulnerability was issued
	Issued time.Time
	// any links to more details about the vulnerability
	Links string
	// the severity string retrieved from the security database
	Severity string
	// a normalized Severity type providing client guaranteed severity information
	NormalizedSeverity claircore.Severity

	// the package information associated with the vulnerability. ideally these fields can be matched
	// to packages discovered by libindex PackageScanner structs.
	Package *VulPackage `gorm:"EMBEDDED;EMBEDDED_PREFIX:package_"`
	// the distribution information associated with the vulnerability.
	Dist *VulDist `gorm:"EMBEDDED;EMBEDDED_PREFIX:dist_"`
	// the repository information associated with the vulnerability
	Repo *VulRepository `gorm:"EMBEDDED;EMBEDDED_PREFIX:repo_"`
	// a string specifying the package version the fix was released in
	FixedInVersion string `gorm:"fixed_in_version"`
	// Range describes the range of versions that are vulnerable.
	RawRange []byte          `gorm:"range"`
	Range    claircore.Range `json:"-"`
}

Vulnerability is the gorm dao for claircore@v1.0.5 All fields should be modified to corresponding claircore package Should not be changed at will

func (*Vulnerability) AfterFind

func (v *Vulnerability) AfterFind(scope *gorm.Scope) (err error)

AfterFind marshal range

Jump to

Keyboard shortcuts

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