db

package
v0.0.0-...-463644e Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImageDto

type ImageDto struct {
	Id        int            `gorm:"column:Id;primaryKey;<-:false"`
	Name      string         `gorm:"column:Name;->;<-:create"`
	BaseImage string         `gorm:"column:BaseImage;->;<-:create"`
	Scans     []ImageScanDto `gorm:"foreignKey:ImageId"`
}

ImageDto has information about a specific docker image and tag Returned by "read" methods for the Repository, e.g. GetLastImageScan

func (ImageDto) TableName

func (ImageDto) TableName() string

type ImageScanDto

type ImageScanDto struct {
	Id              int                `gorm:"column:Id;primaryKey;<-:false"`
	ImageId         int                `gorm:"column:ImageId;<-:false"`
	ScanTime        time.Time          `gorm:"column:ScanTime;<-:false"`
	ScanSuccess     bool               `gorm:"column:ScanSuccess;<-:false"`
	Vulnerabilities []VulnerabilityDto `gorm:"many2many:ImageScanVulnerabilities;joinForeignKey:ImageScanId;joinReferences:VulnerabilityId"` // https://gorm.io/docs/many_to_many.html
}

ImageScanDto has information about a spcific vulnerability scan for a docker image Returned by "read" methods for the Repository, e.g. GetLastImageScan

func (ImageScanDto) TableName

func (ImageScanDto) TableName() string

type Repository

type Repository interface {
	// GetLastImageScan returns the last vulnerability scan for an image
	GetLastImageScan(ctx context.Context, image string) (*ImageScanDto, error)
	// RegisterImageScan stores information about a vulnerability scan for an image
	RegisterImageScan(ctx context.Context, image string, baseImage *string, scanTime time.Time, success bool, vulnerabilities []VulnerabilityBulkDto, identifiers []VulnerabilityIdentifierBulkDto, references []VulnerabilityReferenceBulkDto) error
}

Repository defines methods for reading and storing data about vulnerability scans

func NewGormRepository

func NewGormRepository(db *gorm.DB) Repository

NewGormRepository returns a Repository using a Gorm ORM (https://gorm.io/index.html) database to access data

type VulnerabilityBulkDto

type VulnerabilityBulkDto struct {
	ExternalId       string
	PackageName      string
	Version          string
	Title            string
	Description      string
	Severity         string
	CVSS             *float32
	CVSSv3           string
	CreationTime     time.Time
	ModificationTime time.Time
	PublicationTime  time.Time
	DisclosureTime   *time.Time
}

VulnerabilityBulkDto defines details about a vulnerability Used as argument when registering a scan with RegisterImageScan in Repository

type VulnerabilityDto

type VulnerabilityDto struct {
	Id               int                          `gorm:"column:Id;primaryKey;<-:false"`
	ExternalId       string                       `gorm:"column:ExternalId;<-:false"`
	PackageName      string                       `gorm:"column:PackageName;<-:false"`
	Version          string                       `gorm:"column:Version;<-:false"`
	Description      string                       `gorm:"column:Description;<-:false"`
	Title            string                       `gorm:"column:Title;<-:false"`
	Severity         string                       `gorm:"column:Severity;<-:false"`
	CVSS             *float32                     `gorm:"column:CVSS;<-:false"`
	CVSSv3           string                       `gorm:"column:CVSSv3;<-:false"`
	CreationTime     time.Time                    `gorm:"column:CreationTime;<-:false"`
	ModificationTime time.Time                    `gorm:"column:ModificationTime;<-:false"`
	PublicationTime  time.Time                    `gorm:"column:PublicationTime;<-:false"`
	DisclosureTime   time.Time                    `gorm:"column:DisclosureTime;<-:false"`
	References       []VulnerabilityReferenceDto  `gorm:"foreignKey:VulnerabilityId"`
	Identifiers      []VulnerabilityIdentifierDto `gorm:"foreignKey:VulnerabilityId"`
}

VulnerabilityDto has information about a vulnerability Returned by "read" methods for the Repository, e.g. GetLastImageScan

func (VulnerabilityDto) TableName

func (VulnerabilityDto) TableName() string

type VulnerabilityIdentifierBulkDto

type VulnerabilityIdentifierBulkDto struct {
	ExternalId     string
	IdentifierType string
	Identifier     string
}

VulnerabilityIdentifierBulkDto defines details about a vulnerability identifier type and value, e.g. CVE, CVE-2011-3374 Used as argument when registering a scan with RegisterImageScan in Repository

type VulnerabilityIdentifierDto

type VulnerabilityIdentifierDto struct {
	VulnerabilityId int    `gorm:"column:VulnerabilityId;primaryKey;<-:false"`
	IdentifierType  string `gorm:"column:IdentifierType;primaryKey;<-:false"`
	Identifier      string `gorm:"column:Identifier;primaryKey;<-:false"`
}

VulnerabilityIdentifierDto defines an identifier type and value for a vulnerability, e.g. CVE, CVE-2011-3374 Returned by "read" methods for the Repository, e.g. GetLastImageScan

func (VulnerabilityIdentifierDto) TableName

func (VulnerabilityIdentifierDto) TableName() string

type VulnerabilityReferenceBulkDto

type VulnerabilityReferenceBulkDto struct {
	ExternalId string
	Url        string
}

VulnerabilityBulkDto defines an external URL with information about the vulnerability Used as argument when registering a scan with RegisterImageScan in Repository

type VulnerabilityReferenceDto

type VulnerabilityReferenceDto struct {
	VulnerabilityId int    `gorm:"column:VulnerabilityId;primaryKey;<-:false"`
	Url             string `gorm:"column:Url;primaryKey;<-:false"`
}

VulnerabilityReferenceDto defines an external URL with information about a vulnerability Returned by "read" methods for the Repository, e.g. GetLastImageScan

func (VulnerabilityReferenceDto) TableName

func (VulnerabilityReferenceDto) TableName() string

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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