db

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveResource

func ArchiveResource(database *Database, resource *model2.Resource) error

func CalculateCompositePriority

func CalculateCompositePriority(finding *model2.SecurityFinding) int

func CountActiveResources

func CountActiveResources(database *Database, category model2.ResourceCategory, resourceType string) (int, error)

func CountExpiredResources

func CountExpiredResources(database *Database, time time.Time) (int, error)

func CountNonArchivedFindings

func CountNonArchivedFindings(database *Database, spaceId string) (int, error)

func CountSecurityFindings

func CountSecurityFindings(database *Database, spaceId string, accountId string, region string) (int, error)

func DeleteExpiresRows added in v0.0.26

func DeleteExpiresRows(database *Database) error

func GetLatestProcessingRun

func GetLatestProcessingRun(database *Database, spaceId string, key string) (*model.ProcessingRun, error)

func GetResource

func GetResource(database *Database, key string) (*model2.Resource, error)

func GetSecurityFindingState

func GetSecurityFindingState(database *Database, securityFindingId string, time time.Time) (*model.StateChange, error)

func GetSecurityFindings

func GetSecurityFindings(database *Database, spaceId string, accountId string, region string, offset int, limit int) ([]*model.SecurityFinding, error)

func GetVulnerability

func GetVulnerability(database *Database, key string) (*model2.Vulnerability, error)

func InitDatabase

func InitDatabase()

func InsertProcessingRun

func InsertProcessingRun(database *Database, spaceId string, key string, periodStart time.Time, periodEnd time.Time) error

func JsonMapAppender

func JsonMapAppender(in []byte, v reflect.Value, flags int) []byte

func JsonMapScanner

func JsonMapScanner(v reflect.Value, rd types.Reader, n int) error

func LoadActiveResources

func LoadActiveResources(database *Database, category model2.ResourceCategory, resourceType string, offset int, limit int) ([]*model2.Resource, error)

func LoadEnabledRules added in v0.0.21

func LoadEnabledRules(database *Database, spaceId string) ([]*model2.SecurityFindingRule, error)

func LoadExpiredResources

func LoadExpiredResources(database *Database, time time.Time, offset int, limit int) ([]*model2.Resource, error)

func LoadNonArchivedFindings

func LoadNonArchivedFindings(database *Database, spaceId string, limit int, offset int) ([]*model2.SecurityFinding, error)

func SaveFinding

func SaveFinding(database *Database, finding *model2.SecurityFinding) error

func SaveFindingChange

func SaveFindingChange(database *Database, change *model2.RuleApplyResult) error

func SaveResource

func SaveResource(database *Database, resource *model2.Resource) error

func SaveSecurityFindingReportRow

func SaveSecurityFindingReportRow(database *Database, row *model.SecurityFindingReportRow) error

func SaveVulnerability

func SaveVulnerability(database *Database, vulnerability *model2.Vulnerability) error

Types

type Database

type Database struct {
	Db *pg.DB
	// contains filtered or unexported fields
}

func NewApplicationDatabase

func NewApplicationDatabase() *Database

func NewDatabase

func NewDatabase(host string, port int, database string, user string, password string, ssl bool, log bool, schemaInstall bool) *Database

func (*Database) Start

func (t *Database) Start() error

func (*Database) Stop

func (t *Database) Stop() error

func (*Database) UpdateSchema

func (t *Database) UpdateSchema() error

type Logger

type Logger struct{}

func (Logger) AfterQuery

func (d Logger) AfterQuery(c context.Context, q *pg.QueryEvent) error

func (Logger) BeforeQuery

func (d Logger) BeforeQuery(c context.Context, q *pg.QueryEvent) (context.Context, error)

Jump to

Keyboard shortcuts

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