core

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunFromInsideCluster

func RunFromInsideCluster()

func RunLocally

func RunLocally(kubeconfigPath string)

Types

type HTTPResponder

type HTTPResponder struct {
	// contains filtered or unexported fields
}

HTTPResponder ...

func NewHTTPResponder

func NewHTTPResponder(model <-chan Model, metricsHandler *metrics) *HTTPResponder

func (*HTTPResponder) AddImage

func (hr *HTTPResponder) AddImage(image common.Image)

func (*HTTPResponder) AddPod

func (hr *HTTPResponder) AddPod(pod common.Pod)

func (*HTTPResponder) DeletePod

func (hr *HTTPResponder) DeletePod(qualifiedName string)

func (*HTTPResponder) Error

func (hr *HTTPResponder) Error(w http.ResponseWriter, r *http.Request, err error, statusCode int)

func (*HTTPResponder) GetMetrics

func (hr *HTTPResponder) GetMetrics(w http.ResponseWriter, r *http.Request)

func (*HTTPResponder) GetModel

func (hr *HTTPResponder) GetModel() string

func (*HTTPResponder) GetNextImage

func (hr *HTTPResponder) GetNextImage(continuation func(nextImage api.NextImage))

func (*HTTPResponder) GetScanResults

func (hr *HTTPResponder) GetScanResults() api.ScanResults

func (*HTTPResponder) NotFound

func (hr *HTTPResponder) NotFound(w http.ResponseWriter, r *http.Request)

func (*HTTPResponder) PostFinishScan

func (hr *HTTPResponder) PostFinishScan(job api.FinishedScanClientJob)

func (*HTTPResponder) UpdateAllPods

func (hr *HTTPResponder) UpdateAllPods(allPods api.AllPods)

func (*HTTPResponder) UpdatePod

func (hr *HTTPResponder) UpdatePod(pod common.Pod)

type HubImageScan

type HubImageScan struct {
	Image common.Image
	Scan  *hub.ImageScan
}

type ImageScanResults

type ImageScanResults struct {
	ScanStatus  ScanStatus
	ScanResults *hub.ImageScan
}

func NewImageScanResults

func NewImageScanResults() *ImageScanResults

type Model

type Model struct {
	// Pods is a map of "<namespace>/<name>" to pod
	Pods                map[string]common.Pod
	Images              map[common.Image]*ImageScanResults
	ImageScanQueue      []common.Image
	ImageHubCheckQueue  []common.Image
	ConcurrentScanLimit int
}

Model is the root of the core model

func NewModel

func NewModel(concurrentScanLimit int) *Model

func (*Model) AddImage

func (model *Model) AddImage(image common.Image)

AddImage adds an image to the model, sets its status to NotScanned, and adds it to the queue for hub checking.

func (*Model) AddPod

func (model *Model) AddPod(newPod common.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 extract 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) MarshalJSON

func (model Model) MarshalJSON() ([]byte, error)

type Perceptor

type Perceptor struct {
	// contains filtered or unexported fields
}

Perceptor ties together: a cluster, scan clients, and a hub. It listens to the cluster to learn about new pods. It keeps track of pods, containers, images, and scan results in a model. It has the hub scan images that have never been seen before. It grabs the scan results from the hub and adds them to its model. It publishes vulnerabilities that the cluster can find out about.

func NewMockedPerceptor

func NewMockedPerceptor() (*Perceptor, error)

NewMockedPerceptor creates a Perceptor which uses a mock scanclient

func NewPerceptor

func NewPerceptor(cfg *PerceptorConfig) (*Perceptor, error)

NewPerceptor creates a Perceptor using a real hub client.

type PerceptorConfig

type PerceptorConfig struct {
	HubHost         string
	HubUser         string
	HubUserPassword string
}

PerceptorConfig contains all configuration for Perceptor

func GetPerceptorConfig

func GetPerceptorConfig() (*PerceptorConfig, error)

GetPerceptorConfig returns a configuration object to configure Perceptor

func (*PerceptorConfig) StartWatch

func (p *PerceptorConfig) 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 ScanStatus

type ScanStatus int

ScanStatus describes the state of an image -- have we checked the hub for it? Have we scanned it? Are we scanning it?

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

Allowed transitions:

  • Unknown -> InHubCheckQueue
  • InHubCheckQueue -> CheckingHub
  • CheckingHub -> InQueue
  • CheckingHub -> Complete
  • InQueue -> RunningScanClient
  • RunningScanClient -> Error
  • RunningScanClient -> RunningHubScan
  • RunningHubScan -> Error
  • RunningHubScan -> Complete
  • Error -> ??? throw it back into the queue?

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