core

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: Apache-2.0 Imports: 8 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

Types

type Config

type Config struct {
	HubHost               string
	HubUser               string
	HubUserPasswordEnvVar string
	ConcurrentScanLimit   int
	UseMockMode           bool
	Port                  int
	LogLevel              string
}

Config contains all configuration for Perceptor

func GetConfig

func GetConfig() (*Config, error)

GetConfig returns a configuration object to configure Perceptor

func (*Config) GetLogLevel

func (config *Config) GetLogLevel() (log.Level, error)

func (*Config) StartWatch

func (p *Config) StartWatch(handler func(fsnotify.Event))

StartWatch will start watching the Perceptor configuration file and call the passed handler function when the configuration file has changed

type Container

type Container struct {
	Image Image
	Name  string
}

func ApiContainerToCoreContainer

func ApiContainerToCoreContainer(apiContainer api.Container) *Container

func NewContainer

func NewContainer(image Image, name string) *Container

type DockerImageSha

type DockerImageSha string

type HubImageScan

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

type Image

type Image struct {
	// Name combines Host, User, and Project
	Name string
	Sha  DockerImageSha
}

func ApiImageToCoreImage

func ApiImageToCoreImage(apiImage api.Image) *Image

func NewImage

func NewImage(name string, sha DockerImageSha) *Image

func (Image) HubProjectName

func (image Image) HubProjectName() string

func (Image) HubProjectNameSearchString

func (image Image) HubProjectNameSearchString() string

func (Image) HubProjectVersionName

func (image Image) HubProjectVersionName() string

func (Image) HubProjectVersionNameSearchString

func (image Image) HubProjectVersionNameSearchString() string

func (Image) HubScanName

func (image Image) HubScanName() string

func (Image) HubScanNameSearchString

func (image Image) HubScanNameSearchString() string

func (*Image) HumanReadableName

func (image *Image) HumanReadableName() string

HumanReadableName returns a nice, easy to read string

func (*Image) PullSpec

func (image *Image) PullSpec() string

PullSpec combines Name with the image sha and should be pullable by Docker

type ImageInfo

type ImageInfo struct {
	ScanStatus             ScanStatus
	TimeOfLastStatusChange time.Time
	ScanResults            *hub.ImageScan
	ImageSha               DockerImageSha
	ImageNames             []string
}

func NewImageInfo

func NewImageInfo(sha DockerImageSha, imageName string) *ImageInfo

func (*ImageInfo) AddImageName

func (imageInfo *ImageInfo) AddImageName(imageName string)

func (*ImageInfo) FirstImageName

func (imageInfo *ImageInfo) FirstImageName() string

func (*ImageInfo) Image

func (imageInfo *ImageInfo) Image() Image

func (*ImageInfo) TimeInCurrentScanStatus

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

type Model

type Model struct {
	// Pods is a map of "<namespace>/<name>" to pod
	Pods                map[string]Pod
	Images              map[DockerImageSha]*ImageInfo
	ImageScanQueue      []DockerImageSha
	ImageHubCheckQueue  []DockerImageSha
	ConcurrentScanLimit int
	Config              *Config
	HubVersion          string
}

Model is the root of the core model

func NewModel

func NewModel(config *Config, hubVersion string) *Model

func (*Model) AddImage

func (model *Model) AddImage(image Image)

AddImage adds an image to the model, adding it to the queue for hub checking.

func (*Model) AddPod

func (model *Model) AddPod(newPod Pod)

AddPod adds a pod and all the images in a pod to the model. If the pod is already present in the model, it will be removed and a new one created in its place. The key is the combination of the pod's namespace and name. It extracts the containers and images from the pod, adding them into the cache.

func (*Model) DeletePod

func (model *Model) DeletePod(podName string)

DeletePod removes the record of a pod, but does not affect images.

func (*Model) FinishRunningScanClient

func (model *Model) FinishRunningScanClient(image *Image, scanClientError error)

func (*Model) GetNextImageFromHubCheckQueue

func (model *Model) GetNextImageFromHubCheckQueue() *Image

func (*Model) GetNextImageFromScanQueue

func (model *Model) GetNextImageFromScanQueue() *Image

func (*Model) InProgressHubScans

func (model *Model) InProgressHubScans() []Image

func (*Model) InProgressScanCount

func (model *Model) InProgressScanCount() int

func (*Model) InProgressScans

func (model *Model) InProgressScans() []DockerImageSha

func (*Model) Metrics

func (model *Model) Metrics() *ModelMetrics

func (*Model) ScanResults

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

func (*Model) ScanResultsForPod

func (model *Model) ScanResultsForPod(podName string) (*PodScan, error)

func (*Model) SetImageScanStatus added in v0.0.15

func (model *Model) SetImageScanStatus(sha DockerImageSha, newScanStatus ScanStatus)

type ModelMetrics

type ModelMetrics 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
}

type Pod

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

func ApiPodToCorePod

func ApiPodToCorePod(apiPod api.Pod) *Pod

func NewPod

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

func (*Pod) QualifiedName

func (pod *Pod) QualifiedName() string

type PodScan added in v0.0.16

type PodScan struct {
	OverallStatus    string
	PolicyViolations int
	Vulnerabilities  int
}

type ScanStatus

type ScanStatus int

ScanStatus describes the state of an image in perceptor

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

func (ScanStatus) MarshalJSON

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

func (ScanStatus) MarshalText

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

func (ScanStatus) String

func (status ScanStatus) String() string

Jump to

Keyboard shortcuts

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