core

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIContainerToCoreContainer

func APIContainerToCoreContainer(apiContainer api.Container) (*model.Container, error)

APIContainerToCoreContainer .....

func APIImageToCoreImage

func APIImageToCoreImage(apiImage api.Image) (*model.Image, error)

APIImageToCoreImage .....

func APIPodToCorePod

func APIPodToCorePod(apiPod api.Pod) (*model.Pod, error)

APIPodToCorePod .....

func RunPerceptor added in v0.0.10

func RunPerceptor(configPath string)

RunPerceptor .....

Types

type Config

type Config struct {
	Hub         *HubConfig
	Timings     *Timings
	UseMockMode bool
	Port        int
	LogLevel    string
}

Config contains all configuration for Perceptor

func (*Config) GetLogLevel

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

GetLogLevel .....

type ConfigManager

type ConfigManager struct {
	ConfigPath string
	// contains filtered or unexported fields
}

ConfigManager handles:

  • getting initial config
  • reporting ongoing changes to config

func NewConfigManager

func NewConfigManager(configPath string, stop <-chan struct{}) *ConfigManager

NewConfigManager ...

func (*ConfigManager) DidReadConfig

func (cm *ConfigManager) DidReadConfig() <-chan *Config

DidReadConfig ...

func (*ConfigManager) GetConfig

func (cm *ConfigManager) GetConfig() (*Config, error)

GetConfig returns a configuration object to configure Perceptor

type HubConfig

type HubConfig struct {
	Hosts                     []string
	User                      string
	PasswordEnvVar            string
	ClientTimeoutMilliseconds int
	Port                      int
	ConcurrentScanLimit       int
	TotalScanLimit            int
}

HubConfig handles Hub-specific configuration

func (*HubConfig) ClientTimeout

func (config *HubConfig) ClientTimeout() time.Duration

ClientTimeout converts the milliseconds to a duration

type HubManager

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

HubManager ...

func NewHubManager

func NewHubManager(newHub hubClientCreator, stop <-chan struct{}) *HubManager

NewHubManager ...

func (*HubManager) FinishScanClient

func (hm *HubManager) FinishScanClient(hubURL string, scanName string, scanErr error) error

FinishScanClient tells the appropriate hub client to start polling for scan completion.

func (*HubManager) HubClients

func (hm *HubManager) HubClients() map[string]hub.ClientInterface

HubClients ...

func (*HubManager) ScanResults

func (hm *HubManager) ScanResults() map[string]map[string]*hub.Scan

ScanResults ...

func (*HubManager) SetHubs

func (hm *HubManager) SetHubs(hubURLs []string)

SetHubs ...

func (*HubManager) StartScanClient

func (hm *HubManager) StartScanClient(hubURL string, scanName string) error

StartScanClient ...

func (*HubManager) Updates

func (hm *HubManager) Updates() <-chan *Update

Updates returns a read-only channel of the combined update stream of each hub.

type HubManagerInterface

type HubManagerInterface interface {
	SetHubs(hubURLs []string)
	HubClients() map[string]hub.ClientInterface
	StartScanClient(hubURL string, scanName string) error
	FinishScanClient(hubURL string, scanName string, err error) error
	ScanResults() map[string]map[string]*hub.Scan
	Updates() <-chan *Update
}

HubManagerInterface ...

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 NewPerceptor

func NewPerceptor(config *Config, timings *Timings, scanScheduler *ScanScheduler, hubManager HubManagerInterface) (*Perceptor, error)

NewPerceptor creates a Perceptor using a real hub client.

func (*Perceptor) AddImage

func (pcp *Perceptor) AddImage(apiImage api.Image) error

AddImage .....

func (*Perceptor) AddPod

func (pcp *Perceptor) AddPod(apiPod api.Pod) error

AddPod .....

func (*Perceptor) DeletePod

func (pcp *Perceptor) DeletePod(qualifiedName string)

DeletePod .....

func (*Perceptor) Error

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

Error .....

func (*Perceptor) GetModel

func (pcp *Perceptor) GetModel() api.Model

GetModel .....

func (*Perceptor) GetNextImage

func (pcp *Perceptor) GetNextImage() api.NextImage

GetNextImage .....

func (*Perceptor) GetScanResults

func (pcp *Perceptor) GetScanResults() api.ScanResults

GetScanResults returns results for:

  • all images that have a scan status of complete
  • all pods for which all their images have a scan status of complete

func (*Perceptor) NotFound

func (pcp *Perceptor) NotFound(w http.ResponseWriter, r *http.Request)

NotFound .....

func (*Perceptor) PostCommand

func (pcp *Perceptor) PostCommand(command *api.PostCommand)

PostCommand .....

func (*Perceptor) PostFinishScan

func (pcp *Perceptor) PostFinishScan(job api.FinishedScanClientJob) error

PostFinishScan .....

func (*Perceptor) UpdateAllImages

func (pcp *Perceptor) UpdateAllImages(allImages api.AllImages) error

UpdateAllImages .....

func (*Perceptor) UpdateAllPods

func (pcp *Perceptor) UpdateAllPods(allPods api.AllPods) error

UpdateAllPods .....

func (*Perceptor) UpdateConfig

func (pcp *Perceptor) UpdateConfig(config *Config)

UpdateConfig ...

func (*Perceptor) UpdatePod

func (pcp *Perceptor) UpdatePod(apiPod api.Pod) error

UpdatePod .....

type RoutineTaskManager

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

RoutineTaskManager manages routine tasks

func NewRoutineTaskManager

func NewRoutineTaskManager(stop <-chan struct{}, timings *Timings) *RoutineTaskManager

NewRoutineTaskManager ...

func (*RoutineTaskManager) GetTimings

func (rtm *RoutineTaskManager) GetTimings() (*Timings, error)

GetTimings gets the timings in a threadsafe way

func (*RoutineTaskManager) SetTimings

func (rtm *RoutineTaskManager) SetTimings(newTimings *Timings)

SetTimings sets the timings in a threadsafe way

type ScanScheduler

type ScanScheduler struct {
	TotalScanLimit      int
	ConcurrentScanLimit int
	HubManager          HubManagerInterface
}

ScanScheduler ...

func (*ScanScheduler) AssignImage

func (s *ScanScheduler) AssignImage(image *m.Image) hub.ClientInterface

AssignImage finds a Hub that is available to scan `image`.

type Timings

type Timings struct {
	CheckForStalledScansPauseHours int
	StalledScanClientTimeoutHours  int
	ModelMetricsPauseSeconds       int
	UnknownImagePauseMilliseconds  int
}

Timings ...

func (*Timings) CheckForStalledScansPause

func (t *Timings) CheckForStalledScansPause() time.Duration

CheckForStalledScansPause ...

func (*Timings) ModelMetricsPause

func (t *Timings) ModelMetricsPause() time.Duration

ModelMetricsPause ...

func (*Timings) StalledScanClientTimeout

func (t *Timings) StalledScanClientTimeout() time.Duration

StalledScanClientTimeout ...

func (*Timings) UnknownImagePause

func (t *Timings) UnknownImagePause() time.Duration

UnknownImagePause ...

type Update

type Update struct {
	HubURL string
	Update hub.Update
}

Update is a wrapper around hub.Update which also tracks which Hub was the source.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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