model

package
v2.2.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLegalTransition added in v0.0.15

func IsLegalTransition(from ScanStatus, to ScanStatus) bool

IsLegalTransition .....

Types

type Container

type Container struct {
	Image Image
	Name  string
}

Container .....

func NewContainer

func NewContainer(image Image, name string) *Container

NewContainer .....

type DockerImageSha

type DockerImageSha string

DockerImageSha .....

func NewDockerImageSha

func NewDockerImageSha(sha string) (DockerImageSha, error)

NewDockerImageSha ensures that the sha is 64 characters.

type HubImageScan

type HubImageScan struct {
	Sha  DockerImageSha
	Scan *hub.ScanResults
	Err  error
}

HubImageScan .....

type Image

type Image struct {
	Repository              string
	Tag                     string
	Sha                     DockerImageSha
	Priority                int
	BlackDuckProjectName    string
	BlackDuckProjectVersion string
}

Image stores the Image configuration

func NewImage

func NewImage(repository string, tag string, sha DockerImageSha, priority int, blackDuckProjectName string, blackDuckProjectVersion string) *Image

NewImage returns the image congifurations

func (Image) GetBlackDuckProjectName

func (image Image) GetBlackDuckProjectName() string

GetBlackDuckProjectName returns the Black Duck project name

func (Image) GetBlackDuckProjectVersionName

func (image Image) GetBlackDuckProjectVersionName() string

GetBlackDuckProjectVersionName returns the Black Duck project version name

func (Image) GetBlackDuckScanName

func (image Image) GetBlackDuckScanName() string

GetBlackDuckScanName returns the Black Duck scan name

func (*Image) PullSpec

func (image *Image) PullSpec() string

PullSpec combines repository with sha and should be pullable by Docker

type ImageInfo

type ImageInfo struct {
	ScanStatus              ScanStatus
	TimeOfLastStatusChange  time.Time
	TimeOfLastRefresh       time.Time
	ScanResults             *hub.ScanResults
	ImageSha                DockerImageSha
	RepoTags                []*RepoTag
	Priority                int
	BlackDuckProjectName    string
	BlackDuckProjectVersion string
}

ImageInfo .....

func NewImageInfo

func NewImageInfo(image Image, repoTag *RepoTag) *ImageInfo

NewImageInfo .....

func (*ImageInfo) AddRepoTag

func (imageInfo *ImageInfo) AddRepoTag(repoTag *RepoTag)

AddRepoTag .....

func (*ImageInfo) FirstRepoTag

func (imageInfo *ImageInfo) FirstRepoTag() *RepoTag

FirstRepoTag .....

func (*ImageInfo) Image

func (imageInfo *ImageInfo) Image() Image

Image .....

func (*ImageInfo) SetPriority

func (imageInfo *ImageInfo) SetPriority(priority int)

SetPriority ...

func (*ImageInfo) SetScanResults

func (imageInfo *ImageInfo) SetScanResults(results *hub.ScanResults)

SetScanResults .....

func (*ImageInfo) TimeInCurrentScanStatus

func (imageInfo *ImageInfo) TimeInCurrentScanStatus() time.Duration

TimeInCurrentScanStatus .....

type ImageTransition

type ImageTransition struct {
	Sha  DockerImageSha
	From string
	To   ScanStatus
	Err  error
	Time time.Time
}

ImageTransition .....

func NewImageTransition

func NewImageTransition(sha DockerImageSha, from string, to ScanStatus, err error) *ImageTransition

NewImageTransition .....

type Metrics

type Metrics struct {
	ScanStatusCounts      map[ScanStatus]int
	NumberOfPods          int
	NumberOfImages        int
	ContainerCounts       map[int]int
	ImageCountHistogram   map[int]int
	PodStatus             map[string]int
	ImageStatus           map[string]int
	PodPolicyViolations   map[int]int
	ImagePolicyViolations map[int]int
	PodVulnerabilities    map[int]int
	ImageVulnerabilities  map[int]int
}

Metrics .....

type Model

type Model struct {
	// Pods is a map of qualified name ("<namespace>/<name>") to pod
	Pods             map[string]Pod
	Images           map[DockerImageSha]*ImageInfo
	ImageScanQueue   *util.PriorityQueue
	ImageTransitions []*ImageTransition
	// contains filtered or unexported fields
}

Model is the root of the core model

func NewModel

func NewModel() *Model

NewModel .....

func (*Model) AddImage

func (model *Model) AddImage(image Image)

AddImage ...

func (*Model) AddPod

func (model *Model) AddPod(pod Pod)

AddPod ...

func (*Model) DeletePod

func (model *Model) DeletePod(podName string)

DeletePod removes the record of a pod, but does not touch its images

func (*Model) FinishScanJob

func (model *Model) FinishScanJob(image *Image, err error)

FinishScanJob should be called when the scan client has finished.

func (*Model) GetImages

func (model *Model) GetImages(status ScanStatus) []DockerImageSha

GetImages returns images in that status

func (*Model) GetMetrics

func (model *Model) GetMetrics() *Metrics

GetMetrics calculates useful metrics for observing the progress of the model over time.

func (*Model) GetModel

func (model *Model) GetModel() *api.CoreModel

GetModel ...

func (*Model) GetNextImage

func (model *Model) GetNextImage() *Image

GetNextImage ...

func (*Model) GetScanResults

func (model *Model) GetScanResults() api.ScanResults

GetScanResults ...

func (*Model) ScanDidFinish

func (model *Model) ScanDidFinish(sha DockerImageSha, scanResults *hub.ScanResults)

ScanDidFinish should be called when: - the Hub scan finishes - upon startup, when scan results are first fetched

func (*Model) SetImages

func (model *Model) SetImages(images []Image)

SetImages ...

func (*Model) SetPods

func (model *Model) SetPods(pods []Pod)

SetPods ...

func (*Model) StartScanClient

func (model *Model) StartScanClient(sha DockerImageSha) error

StartScanClient ...

func (*Model) UpdatePod

func (model *Model) UpdatePod(pod Pod)

UpdatePod ...

type Pod

type Pod struct {
	Name       string
	UID        string
	Namespace  string
	Containers []Container
}

Pod .....

func NewPod

func NewPod(name string, uid string, namespace string, containers []Container) *Pod

NewPod .....

func (*Pod) QualifiedName

func (pod *Pod) QualifiedName() string

QualifiedName .....

type RepoTag

type RepoTag struct {
	Repository string
	Tag        string
}

RepoTag combines a Docker repository and tag

type Scan

type Scan struct {
	OverallStatus    string
	PolicyViolations int
	Vulnerabilities  int
}

Scan denotes the status of the scan with vulnerability and policy violation of the status

type ScanStatus

type ScanStatus int

ScanStatus describes the state of an image in perceptor

const (
	ScanStatusUnknown           ScanStatus = iota
	ScanStatusInQueue           ScanStatus = iota
	ScanStatusRunningScanClient ScanStatus = iota
	ScanStatusRunningHubScan    ScanStatus = iota
	ScanStatusComplete          ScanStatus = iota
)

.....

func (ScanStatus) MarshalJSON

func (status ScanStatus) MarshalJSON() ([]byte, error)

MarshalJSON .....

func (ScanStatus) MarshalText

func (status ScanStatus) MarshalText() (text []byte, err error)

MarshalText .....

func (ScanStatus) String

func (status ScanStatus) String() string

String .....

Jump to

Keyboard shortcuts

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