postgresmodels

package
v0.0.220 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttackChainNode added in v0.0.205

type AttackChainNode struct {
	gorm.Model           // ID, CreatedAt, UpdatedAt, DeletedAt - ID is required for linking nodes
	Name          string `gorm:"not null"`
	AttackChainID string `gorm:"not null"` // hash of cluster/resourceID
	CustomerGUID  string `gorm:"not null"`
	IsRoot        bool   `gorm:"not null"`
}

func (AttackChainNode) TableName added in v0.0.205

func (AttackChainNode) TableName() string

type AttackChainNodeControlsRelation added in v0.0.205

type AttackChainNodeControlsRelation struct {
	BaseModel
	NodeID uint            `gorm:"primaryKey; not null"`
	Node   AttackChainNode `gorm:"foreignKey:NodeID"`

	// ControlID = failed or ignored control ID that is associated with the node.
	ControlID string `gorm:"primaryKey; type:varchar(255);not null"`
}

func (AttackChainNodeControlsRelation) TableName added in v0.0.205

type AttackChainNodeImageScanRelation added in v0.0.205

type AttackChainNodeImageScanRelation struct {
	BaseModel
	NodeID uint            `gorm:"primaryKey; not null"`
	Node   AttackChainNode `gorm:"foreignKey:NodeID"`

	// ImageScanId = hash of customerGUID, cluster, containerSpecID
	// Should be used instead of ContainersScanID
	ImageScanId string `gorm:"primaryKey; not null"`
}

func (AttackChainNodeImageScanRelation) TableName added in v0.0.205

type AttackChainNodeRelatedResourcesRelation added in v0.0.205

type AttackChainNodeRelatedResourcesRelation struct {
	BaseModel
	NodeID     uint            `gorm:"primaryKey; not null"`
	Node       AttackChainNode `gorm:"foreignKey:NodeID"`
	ResourceID string          `gorm:"primaryKey; not null"`
}

func (AttackChainNodeRelatedResourcesRelation) TableName added in v0.0.205

type AttackChainNodeRelation added in v0.0.205

type AttackChainNodeRelation struct {
	BaseModel
	ParentNode   AttackChainNode `gorm:"foreignKey:ParentNodeID"`
	ParentNodeID uint            `gorm:"primaryKey; not null"`
	ChildNode    AttackChainNode `gorm:"foreignKey:ChildNodeID"`
	ChildNodeID  uint            `gorm:"primaryKey; not null"`
}

func (AttackChainNodeRelation) TableName added in v0.0.205

func (AttackChainNodeRelation) TableName() string

type AttackChainState added in v0.0.217

type AttackChainState struct {
	// BaseModel.CreatedAt is the former FirstSeen and CreationTime which are the same
	BaseModel

	// primary keys
	AttackChainID   string `gorm:"primaryKey;not null"` // name/cluster/resourceID
	CustomerGUID    string `gorm:"primaryKey;not null"`
	AttackTrackName string `gorm:"primaryKey;not null"`

	AttackTrackDescription string

	// attributes["cluster"], attributes["namespace"], attributes["kind"], attributes["name"]
	Resource     datatypes.JSON // designator attributes
	ResourceHash string         `gorm:"not null"` // hash of resource name/namespace/kind/apiversion/cluster (Extracted from designator attribues)
	ClusterName  string         `gorm:"not null"`

	LatestReportGUID string `gorm:"not null"` // latest reportGUID in which this attack chain was identified

	Status string // "active"/ "fixed"

	// processing status is updated by the UI once a scan is initiated for all relevant clusters (connected) of the customerGUID.
	// "done" is updated by the attack chain engine once finished processing.
	ProcessingStatus string    `gorm:"not null"` // "processing"/ "done"
	ViewedMainScreen time.Time // updated by UI - if the attack chain was viewed by the user// New badge

	RootNode   AttackChainNode `gorm:"foreignKey:RootNodeID"`
	RootNodeID uint            `gorm:"not null"`
}

func (AttackChainState) TableName added in v0.0.217

func (AttackChainState) TableName() string

type BaseModel

type BaseModel struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type BaseReport added in v0.0.212

type BaseReport struct {

	// Total number of chunks expected. Will be populated with the (ReportNumber of the LastReport + 1) (IsLastReport == true)
	// If not known yet (i.e. IsLastReport not recieved yet), will be set to -1
	TotalChunksExpected int

	//specify the total number of chunks recieved so far - will be increment by one on each chunk recieved.
	TotalChunksRecieved int

	// set to True when TotalChunksExpected == TotalChunksRecieved
	Completed bool
}

type ClusterPostureReport added in v0.0.218

type ClusterPostureReport struct {
	BaseModel
	ReportGUID               string `gorm:"primaryKey"`
	ClusterGUID              string
	ClusterName              string
	CustomerGUID             string
	Score                    float32
	Timestamp                time.Time
	WorkerNodeCount          int
	KubescapeVersion         string
	KubernetesVersion        string
	HelmChartVersion         string
	RegoLibraryVersion       string
	TotalControls            int
	FailedControls           int
	SkippedControls          int
	CriticalSeverityControls int
	HighSeverityControls     int
	MediumSeverityControls   int
	LowSeverityControls      int
}

type ContextualVulnerabilityFinding added in v0.0.182

type ContextualVulnerabilityFinding struct {
	VulnerabilityFinding     `gorm:"embedded"`
	VulnerabilityScanSummary VulnerabilityScanSummary `gorm:"foreignKey:ImageScanId"`
}

ContextualVulnerabilityFinding is a VulnerabilityFinding with a VulnerabilityScanSummary, do not auto-migrate it uses only for retreiving data from db

func (ContextualVulnerabilityFinding) TableName added in v0.0.182

type ControlScanResult added in v0.0.218

type ControlScanResult struct {
	BaseModel
	ControlID                  string `gorm:"primaryKey"`
	ReportGUID                 string `gorm:"primaryKey"`
	FrameworkName              string `gorm:"primaryKey"`
	Name                       string
	Status                     string
	SubStatus                  string
	StatusCode                 int
	ComplianceScore            float32
	AffectedResourcesCount     int
	FailedResourcesCount       int
	SkippedResourcesCount      int
	WarningResourcesCount      int
	TotalScannedResourcesCount int
}

type FrameworkSummary added in v0.0.218

type FrameworkSummary struct {
	BaseModel
	ReportGUID      string `gorm:"primaryKey"`
	FrameworkName   string `gorm:"primaryKey"`
	ComplianceScore float32
	TotalControls   int
	FailedControls  int
	SkippedControls int
	TypeTags        pq.StringArray `gorm:"type:text[]"`
}

We need this table for quicker queries although it could be calculated from ControlScanResult

type ReportStatus added in v0.0.218

type ReportStatus struct {
	BaseModel
	ReportGUID          string `gorm:"primaryKey"`
	TotalChunksExpected int
	TotalChunksReceived int
	Completed           bool
}

type Resource added in v0.0.218

type Resource struct {
	BaseModel
	ResourceID        string `gorm:"primaryKey"`
	ReportGUID        string `gorm:"primaryKey"`
	SPIFFE            string
	Designators       datatypes.JSON `gorm:"type:json"` //Portal designators
	ResourceObjectRef string         //external storage ref(e.g. S3 bucket:key) to the resource file
}

type ResourceContainer added in v0.0.218

type ResourceContainer struct {
	BaseModel
	ResourceID    string `gorm:"primaryKey"`
	ReportGUID    string `gorm:"primaryKey"`
	ContainerName string `gorm:"primaryKey"`
	Image         string
	ImageHash     string
}

type ResourceControlResult added in v0.0.218

type ResourceControlResult struct {
	BaseModel
	ResourceID          string   `gorm:"primaryKey"`
	ReportGUID          string   `gorm:"primaryKey"`
	FrameworkName       string   `gorm:"primaryKey"`
	ControlID           string   `gorm:"primaryKey"`
	Resource            Resource `gorm:"foreignKey:ResourceID,ReportGUID"`
	StatusCode          int
	StatusText          string
	SubStatusText       string
	IgnoreRulesIDs      pq.StringArray `gorm:"type:text[]"`
	SystemRulesNames    pq.StringArray `gorm:"type:text[]"`
	RelatedResourcesIDs pq.StringArray `gorm:"type:text[]"`
}

type ResourceFixPath added in v0.0.218

type ResourceFixPath struct {
	ResourceID string `gorm:"primaryKey"`
	ReportGUID string `gorm:"primaryKey"`
	ControlID  string `gorm:"primaryKey"`
	FailedPath string `gorm:"primaryKey"`
	FixCommand string `gorm:"primaryKey"`
	FixPath    string `gorm:"primaryKey"`
	FixValue   string
}

type Vulnerability

type Vulnerability struct {
	BaseModel
	Name          string `gorm:"primaryKey"`
	Severity      string
	SeverityScore int
	IsRCE         bool
	Links         pq.StringArray `gorm:"type:text[]"`
	Description   string
}

type VulnerabilityFinding

type VulnerabilityFinding struct {
	BaseModel
	VulnerabilityName string        `gorm:"primaryKey"`
	Vulnerability     Vulnerability `gorm:"foreignKey:VulnerabilityName"`
	ImageScanId       string        `gorm:"primaryKey"`
	Component         string        `gorm:"primaryKey"`
	ComponentVersion  string        `gorm:"primaryKey"`
	LayerHash         string        `gorm:"primaryKey"`
	FixAvailable      *bool
	FixedInVersion    string
	LayerIndex        *int
	LayerCommand      string
	IsRelevant        *bool
	RelevantLabel     string
	IsIgnored         *bool
	IgnoreRuleIds     pq.StringArray `gorm:"type:text[]"`
}

type VulnerabilityScanSummary

type VulnerabilityScanSummary struct {
	BaseModel
	BaseReport
	ScanKind                   string
	ImageScanId                string `gorm:"primaryKey"`
	ContainerSpecId            string
	Timestamp                  time.Time
	CustomerGuid               string
	Wlid                       string
	Designators                datatypes.JSON
	ImageRegistry              string
	ImageRepository            string
	ImageTag                   string
	ImageHash                  string
	JobIds                     pq.StringArray `gorm:"type:text[]"`
	Status                     string
	Errors                     pq.StringArray               `gorm:"type:text[]"`
	Findings                   []VulnerabilityFinding       `gorm:"foreignKey:ImageScanId"`
	VulnerabilitySeverityStats []VulnerabilitySeverityStats `gorm:"foreignKey:ImageScanId"`
	IsStub                     *bool                        // if true, this is a stub scan summary, and the actual scan summary is not yet available. Should be deleted once we have the real one.
}

type VulnerabilitySeverityStats added in v0.0.179

type VulnerabilitySeverityStats struct {
	BaseModel
	ImageScanId                  string         `gorm:"primaryKey"`
	Severity                     string         `gorm:"primaryKey"`
	DayDate                      datatypes.Date `gorm:"primaryKey"`
	SeverityScore                int
	TotalCount                   int64
	RCEFixCount                  int64
	FixAvailableOfTotalCount     int64
	RelevantCount                int64
	FixAvailableForRelevantCount int64
	RCECount                     int64
	UrgentCount                  int64
	NeglectedCount               int64
	HealthStatus                 string
}

Jump to

Keyboard shortcuts

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