core

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: 16 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 starts the perceptor

Types

type BlackDuckConfig

type BlackDuckConfig struct {
	ConnectionsEnvironmentVariableName string
	TLSVerification                    bool
}

BlackDuckConfig handles BlackDuck-specific configuration

type Config

type Config struct {
	BlackDuck *BlackDuckConfig
	Perceptor *PerceptorConfig
	LogLevel  string
}

Config stores the input perceptor configuration

func (*Config) GetLogLevel

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

GetLogLevel returns the log level

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 returns the configuration manager

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 Host

type Host struct {
	Scheme              string
	Domain              string // it can be domain name or ip address
	Port                int
	User                string
	Password            string
	ConcurrentScanLimit int
}

Host configures the Black Duck hosts

type HubManager

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

HubManager stores the Black Duck Manager configuration

func NewHubManager

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

NewHubManager returns the new Black Duck Manager configuration

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.Hub

HubClients returns the list of Black Duck instance

func (*HubManager) ScanResults

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

ScanResults returns the scan results

func (*HubManager) SetHubs

func (hm *HubManager) SetHubs(hubs map[string]*Host)

SetHubs setup the Black Duck

func (*HubManager) StartScanClient

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

StartScanClient starts the Black Duck client

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(hubs map[string]*Host)
	HubClients() map[string]*hub.Hub
	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 includes all methods related to setup the Black Duck

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 adds an image to the model

func (*Perceptor) AddPod

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

AddPod adds the pod to the model

func (*Perceptor) DeletePod

func (pcp *Perceptor) DeletePod(qualifiedName string)

DeletePod deletes the pod from the model

func (*Perceptor) Error

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

Error logs the http client errors

func (*Perceptor) GetModel

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

GetModel returns the api model

func (*Perceptor) GetNextImage

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

GetNextImage returns the next image from the queue

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 logs the http client not found error

func (*Perceptor) PostCommand

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

PostCommand resets the circuit breaker

func (*Perceptor) PostFinishScan

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

PostFinishScan executes the post finished scan job

func (*Perceptor) UpdateAllImages

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

UpdateAllImages updates all images in the model

func (*Perceptor) UpdateAllPods

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

UpdateAllPods updates all pods in the model

func (*Perceptor) UpdateConfig

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

UpdateConfig ...

func (*Perceptor) UpdatePod

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

UpdatePod updates the pod in the model

type PerceptorConfig

type PerceptorConfig struct {
	Timings     *Timings
	UseMockMode bool
	Port        int
}

PerceptorConfig stores the perceptor configuration

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 {
	HubManager HubManagerInterface
}

ScanScheduler stores the scan scheduler

func (*ScanScheduler) AssignImage

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

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

type Timings

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

Timings stores all timings configuration that is used for various operations

func (*Timings) CheckForStalledScansPause

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

CheckForStalledScansPause returns an interval in hours to check the stalled scans

func (*Timings) ClientTimeout

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

ClientTimeout returns the Black Duck client timeout

func (*Timings) ModelMetricsPause

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

ModelMetricsPause returns an interval to pause the model metrics

func (*Timings) StalledScanClientTimeout

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

StalledScanClientTimeout returns client timeout in hours for the stalled scans

func (*Timings) UnknownImagePause

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

UnknownImagePause returns an interval in milliseconds to check for unknown images

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