Documentation ¶
Index ¶
- Constants
- Variables
- func MinDuration(left time.Duration, right time.Duration) time.Duration
- type CircuitBreaker
- type CircuitBreakerState
- type Client
- type ClientStatus
- type CodeLocation
- type DidFindScan
- type DidFinishScan
- type DidRefreshScan
- type Hub
- func (hub *Hub) ConcurrentScanLimit() int
- func (hub *Hub) FinishScanClient(scanName string, scanErr error)
- func (hub *Hub) HasFetchedScans() <-chan bool
- func (hub *Hub) Host() string
- func (hub *Hub) InProgressScans() <-chan []string
- func (hub *Hub) Model() <-chan *api.ModelBlackDuck
- func (hub *Hub) ResetCircuitBreaker()
- func (hub *Hub) ScanResults() <-chan map[string]*Scan
- func (hub *Hub) ScansCount() <-chan int
- func (hub *Hub) StartScanClient(scanName string)
- func (hub *Hub) Stop()
- func (hub *Hub) StopCh() <-chan struct{}
- func (hub *Hub) Updates() <-chan Update
- type ImageInterface
- type MockRawClient
- func (mhc *MockRawClient) CurrentVersion() (*hubapi.CurrentVersion, error)
- func (mhc *MockRawClient) DeleteCodeLocation(scanName string) error
- func (mhc *MockRawClient) DeleteProjectVersion(name string) error
- func (mhc *MockRawClient) GetProject(link hubapi.ResourceLink) (*hubapi.Project, error)
- func (mhc *MockRawClient) GetProjectVersion(link hubapi.ResourceLink) (*hubapi.ProjectVersion, error)
- func (mhc *MockRawClient) GetProjectVersionPolicyStatus(link hubapi.ResourceLink) (*hubapi.ProjectVersionPolicyStatus, error)
- func (mhc *MockRawClient) GetProjectVersionRiskProfile(link hubapi.ResourceLink) (*hubapi.ProjectVersionRiskProfile, error)
- func (mhc *MockRawClient) ListAllCodeLocations(options *hubapi.GetListOptions) (*hubapi.CodeLocationList, error)
- func (mhc *MockRawClient) ListProjects(options *hubapi.GetListOptions) (*hubapi.ProjectList, error)
- func (mhc *MockRawClient) ListScanSummaries(link hubapi.ResourceLink) (*hubapi.ScanSummaryList, error)
- func (mhc *MockRawClient) Login(username string, password string) error
- func (mhc *MockRawClient) SetTimeout(timeout time.Duration)
- type Model
- func (model *Model) FinishScanClient(scanName string, scanErr error)
- func (model *Model) HasFetchedScans() <-chan bool
- func (model *Model) InProgressScans() <-chan []string
- func (model *Model) Model() <-chan *api.ModelBlackDuck
- func (model *Model) ScanResults() <-chan map[string]*Scan
- func (model *Model) ScansCount() <-chan int
- func (model *Model) StartScanClient(scanName string)
- func (model *Model) Updates() <-chan Update
- type PolicyStatus
- type Project
- type RawClientInterface
- type RiskProfile
- type RiskProfileStatusCounts
- type Scan
- type ScanResults
- type ScanStage
- type ScanSummary
- type ScanSummaryStatus
- type Timings
- type Update
- type Version
Constants ¶
const PolicyStatusTypeInViolation = "IN_VIOLATION"
PolicyStatusTypeInViolation denotes policy status type IN_VIOLATION
const PolicyStatusTypeInViolationOverridden = "IN_VIOLATION_OVERRIDDEN"
PolicyStatusTypeInViolationOverridden denotes policy status type IN_VIOLATION_OVERRIDDEN
const PolicyStatusTypeNotInViolation = "NOT_IN_VIOLATION"
PolicyStatusTypeNotInViolation denotes policy status type NOT_IN_VIOLATION
const RiskProfileCategoryActivity = "ACTIVITY"
RiskProfileCategoryActivity denotes the type ACTIVITY in Risk Profile category
const RiskProfileCategoryLicense = "LICENSE"
RiskProfileCategoryLicense denotes the type LICENSE in Risk Profile category
const RiskProfileCategoryOperational = "OPERATIONAL"
RiskProfileCategoryOperational denotes the type OPERATIONAL in Risk Profile category
const RiskProfileCategoryVersion = "VERSION"
RiskProfileCategoryVersion denotes the type VERSION in Risk Profile category
const RiskProfileCategoryVulnerability = "VULNERABILITY"
RiskProfileCategoryVulnerability denotes the type VULNERABILITY in Risk Profile category
const RiskProfileStatusCritical = "CRITICAL"
RiskProfileStatusCritical denotes risk profile status CRITICAL
const RiskProfileStatusHigh = "HIGH"
RiskProfileStatusHigh denotes risk profile status HIGH
const RiskProfileStatusLow = "LOW"
RiskProfileStatusLow denotes risk profile status LOW
const RiskProfileStatusMedium = "MEDIUM"
RiskProfileStatusMedium denotes risk profile status MEDIUM
const RiskProfileStatusOK = "OK"
RiskProfileStatusOK denotes risk profile status OK
const RiskProfileStatusUnknown = "UNKNOWN"
RiskProfileStatusUnknown denotes risk profile status UNKNOWN
Variables ¶
var DefaultTimings = &Timings{ FetchAllScansPause: 999999 * time.Hour, ScanCompletionPause: 1 * time.Minute, FetchUnknownScansPause: 30 * time.Second, GetMetricsPause: 15 * time.Second, LoginPause: 30 * time.Minute, RefreshScanThreshold: 1 * time.Hour, }
DefaultTimings ...
Functions ¶
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker .....
func NewCircuitBreaker ¶
func NewCircuitBreaker(host string, maxBackoffDuration time.Duration) *CircuitBreaker
NewCircuitBreaker .....
func (*CircuitBreaker) IssueRequest ¶
func (cb *CircuitBreaker) IssueRequest(description string, request func() error) error
IssueRequest synchronously:
- checks whether it's enabled
- runs 'request'
- looks at the result of 'request', disabling itself on failure
func (*CircuitBreaker) Model ¶
func (cb *CircuitBreaker) Model() *api.ModelCircuitBreaker
Model dumps the current state of the circuit breaker
func (*CircuitBreaker) Reset ¶
func (cb *CircuitBreaker) Reset()
Reset reenables the circuit breaker regardless of its current state, and clears out ConsecutiveFailures and NextCheckTime
type CircuitBreakerState ¶
type CircuitBreakerState int
CircuitBreakerState .....
const ( CircuitBreakerStateDisabled CircuitBreakerState = iota CircuitBreakerStateEnabled CircuitBreakerState = iota CircuitBreakerStateChecking CircuitBreakerState = iota )
.....
func (CircuitBreakerState) MarshalJSON ¶
func (state CircuitBreakerState) MarshalJSON() ([]byte, error)
MarshalJSON .....
func (CircuitBreakerState) MarshalText ¶
func (state CircuitBreakerState) MarshalText() (text []byte, err error)
MarshalText .....
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client combines a raw hub client with a circuit breaker
func NewClient ¶
func NewClient(username string, password string, host string, rawClient RawClientInterface) *Client
NewClient returns a new Client.
func (*Client) SetTimeout ¶
SetTimeout is currently not concurrent-safe, and should be made so TODO
type ClientStatus ¶
type ClientStatus int
ClientStatus describes the state of a hub client
const ( ClientStatusError ClientStatus = iota ClientStatusUp ClientStatus = iota ClientStatusDown ClientStatus = iota )
.....
func (ClientStatus) MarshalJSON ¶
func (status ClientStatus) MarshalJSON() ([]byte, error)
MarshalJSON .....
func (ClientStatus) MarshalText ¶
func (status ClientStatus) MarshalText() (text []byte, err error)
MarshalText .....
type CodeLocation ¶
type CodeLocation struct { ScanSummaries []ScanSummary CreatedAt string MappedProjectVersion string Name string CodeLocationType string URL string UpdatedAt string }
CodeLocation .....
type DidFinishScan ¶
type DidFinishScan struct { Name string Results *ScanResults }
DidFinishScan ...
type DidRefreshScan ¶
type DidRefreshScan struct { Name string Results *ScanResults }
DidRefreshScan ...
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub stores the Black Duck configuration
func NewHub ¶
func NewHub(username string, password string, host string, concurrentScanLimit int, rawClient RawClientInterface, timings *Timings) *Hub
NewHub returns a new Black Duck. It will not be logged in.
func (*Hub) ConcurrentScanLimit ¶
ConcurrentScanLimit return the concurrent scan limit
func (*Hub) FinishScanClient ¶
FinishScanClient finishes the scan client
func (*Hub) HasFetchedScans ¶
HasFetchedScans return whether there is any fetched scans
func (*Hub) InProgressScans ¶
InProgressScans return the Inprogress scan count of the Black Duck instance
func (*Hub) ResetCircuitBreaker ¶
func (hub *Hub) ResetCircuitBreaker()
ResetCircuitBreaker resets the circuit breaker
func (*Hub) ScanResults ¶
ScanResults return the scan results
func (*Hub) ScansCount ¶
ScansCount return the Black Duck scan count
func (*Hub) StartScanClient ¶
StartScanClient starts the scan client
type ImageInterface ¶ added in v0.0.5
type ImageInterface interface { HubProjectNameSearchString() string HubProjectVersionNameSearchString() string HubScanNameSearchString() string }
ImageInterface .....
type MockRawClient ¶
MockRawClient ...
func NewMockRawClient ¶
func NewMockRawClient(shouldFail bool, initialCodeLocationNames []string) *MockRawClient
NewMockRawClient ...
func (*MockRawClient) CurrentVersion ¶
func (mhc *MockRawClient) CurrentVersion() (*hubapi.CurrentVersion, error)
CurrentVersion ...
func (*MockRawClient) DeleteCodeLocation ¶
func (mhc *MockRawClient) DeleteCodeLocation(scanName string) error
DeleteCodeLocation ...
func (*MockRawClient) DeleteProjectVersion ¶
func (mhc *MockRawClient) DeleteProjectVersion(name string) error
DeleteProjectVersion ...
func (*MockRawClient) GetProject ¶
func (mhc *MockRawClient) GetProject(link hubapi.ResourceLink) (*hubapi.Project, error)
GetProject ...
func (*MockRawClient) GetProjectVersion ¶
func (mhc *MockRawClient) GetProjectVersion(link hubapi.ResourceLink) (*hubapi.ProjectVersion, error)
GetProjectVersion ...
func (*MockRawClient) GetProjectVersionPolicyStatus ¶
func (mhc *MockRawClient) GetProjectVersionPolicyStatus(link hubapi.ResourceLink) (*hubapi.ProjectVersionPolicyStatus, error)
GetProjectVersionPolicyStatus ...
func (*MockRawClient) GetProjectVersionRiskProfile ¶
func (mhc *MockRawClient) GetProjectVersionRiskProfile(link hubapi.ResourceLink) (*hubapi.ProjectVersionRiskProfile, error)
GetProjectVersionRiskProfile ...
func (*MockRawClient) ListAllCodeLocations ¶
func (mhc *MockRawClient) ListAllCodeLocations(options *hubapi.GetListOptions) (*hubapi.CodeLocationList, error)
ListAllCodeLocations ...
func (*MockRawClient) ListProjects ¶
func (mhc *MockRawClient) ListProjects(options *hubapi.GetListOptions) (*hubapi.ProjectList, error)
ListProjects ...
func (*MockRawClient) ListScanSummaries ¶
func (mhc *MockRawClient) ListScanSummaries(link hubapi.ResourceLink) (*hubapi.ScanSummaryList, error)
ListScanSummaries ...
func (*MockRawClient) Login ¶
func (mhc *MockRawClient) Login(username string, password string) error
Login ...
func (*MockRawClient) SetTimeout ¶
func (mhc *MockRawClient) SetTimeout(timeout time.Duration)
SetTimeout ...
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model stores the Black Duck model
func NewModel ¶
func NewModel(host string, stop <-chan struct{}, fetchScan func(string) (*ScanResults, error)) *Model
NewModel return the Black Duck model
func (*Model) FinishScanClient ¶
FinishScanClient finishes the scan client
func (*Model) HasFetchedScans ¶
HasFetchedScans checks whether there is any has fetched scans
func (*Model) InProgressScans ¶
InProgressScans returns the inprogress scan count
func (*Model) Model ¶
func (model *Model) Model() <-chan *api.ModelBlackDuck
Model returns the model
func (*Model) ScanResults ¶
ScanResults returns the scan results
func (*Model) ScansCount ¶
ScansCount returns the scan count
func (*Model) StartScanClient ¶
StartScanClient starts the scan client
type PolicyStatus ¶
type PolicyStatus struct { OverallStatus string UpdatedAt string ComponentVersionStatusCounts map[string]int }
PolicyStatus .....
func (*PolicyStatus) ViolationCount ¶
func (ps *PolicyStatus) ViolationCount() int
ViolationCount .....
type RawClientInterface ¶
type RawClientInterface interface { CurrentVersion() (*hubapi.CurrentVersion, error) SetTimeout(timeout time.Duration) Login(username string, password string) error ListAllCodeLocations(options *hubapi.GetListOptions) (*hubapi.CodeLocationList, error) ListProjects(options *hubapi.GetListOptions) (*hubapi.ProjectList, error) GetProject(link hubapi.ResourceLink) (*hubapi.Project, error) GetProjectVersion(link hubapi.ResourceLink) (*hubapi.ProjectVersion, error) ListScanSummaries(link hubapi.ResourceLink) (*hubapi.ScanSummaryList, error) GetProjectVersionRiskProfile(link hubapi.ResourceLink) (*hubapi.ProjectVersionRiskProfile, error) GetProjectVersionPolicyStatus(link hubapi.ResourceLink) (*hubapi.ProjectVersionPolicyStatus, error) DeleteProjectVersion(name string) error DeleteCodeLocation(name string) error }
RawClientInterface provides an interface around hub-client-go's client, allowing it to be mocked for testing.
type RiskProfile ¶
type RiskProfile struct { Categories map[string]RiskProfileStatusCounts BomLastUpdatedAt string }
RiskProfile .....
func (*RiskProfile) CriticalAndHighRiskVulnerabilityCount ¶
func (rp *RiskProfile) CriticalAndHighRiskVulnerabilityCount() int
CriticalAndHighRiskVulnerabilityCount returns the combination of CRITICAL and HIGH risk profile count
type RiskProfileStatusCounts ¶ added in v0.0.8
RiskProfileStatusCounts .....
func (*RiskProfileStatusCounts) CriticalRiskVulnerabilityCount ¶
func (r *RiskProfileStatusCounts) CriticalRiskVulnerabilityCount() int
CriticalRiskVulnerabilityCount return the CRITICAL vulnerability count
func (*RiskProfileStatusCounts) HighRiskVulnerabilityCount ¶ added in v0.0.8
func (r *RiskProfileStatusCounts) HighRiskVulnerabilityCount() int
HighRiskVulnerabilityCount .....
type Scan ¶
type Scan struct { Stage ScanStage ScanResults *ScanResults }
Scan is a wrapper around a Hub code location, and full scan results. If `ScanResults` is nil, that means the ScanResults have not been fetched yet.
type ScanResults ¶
type ScanResults struct { RiskProfile RiskProfile PolicyStatus PolicyStatus ScanSummaries []ScanSummary ComponentsHref string CodeLocationCreatedAt string CodeLocationHref string CodeLocationMappedProjectVersion string CodeLocationName string CodeLocationType string CodeLocationURL string CodeLocationUpdatedAt string }
ScanResults models the results that we expect to get from the hub after scanning a docker image.
func (*ScanResults) IsDone ¶
func (scan *ScanResults) IsDone() bool
IsDone returns true if at least one scan summary is successfully finished.
func (*ScanResults) OverallStatus ¶
func (scan *ScanResults) OverallStatus() string
OverallStatus .....
func (*ScanResults) PolicyViolationCount ¶
func (scan *ScanResults) PolicyViolationCount() int
PolicyViolationCount .....
func (*ScanResults) ScanSummaryStatus ¶
func (scan *ScanResults) ScanSummaryStatus() ScanSummaryStatus
ScanSummaryStatus looks through all the scan summaries and:
- 1+ success: returns success
- 0 success, 1+ inprogress: returns inprogress
- 0 success, 0 inprogress: returns failure
TODO: weird corner cases:
- no scan summaries ... ? should that be inprogress, or error? or should we just assume that we'll always have at least 1?
func (*ScanResults) VulnerabilityCount ¶
func (scan *ScanResults) VulnerabilityCount() int
VulnerabilityCount .....
type ScanStage ¶
type ScanStage int
ScanStage describes the current stage of the scan
type ScanSummary ¶
type ScanSummary struct { CreatedAt string Status ScanSummaryStatus UpdatedAt string }
ScanSummary .....
func NewScanSummaryFromHub ¶
func NewScanSummaryFromHub(hubScanSummary hubapi.ScanSummary) *ScanSummary
NewScanSummaryFromHub .....
type ScanSummaryStatus ¶ added in v0.0.15
type ScanSummaryStatus int
ScanSummaryStatus .....
const ( ScanSummaryStatusInProgress ScanSummaryStatus = iota ScanSummaryStatusSuccess ScanSummaryStatus = iota ScanSummaryStatusFailure ScanSummaryStatus = iota )
.....
func (ScanSummaryStatus) String ¶ added in v0.0.15
func (status ScanSummaryStatus) String() string
String .....
type Timings ¶
type Timings struct { ScanCompletionPause time.Duration FetchUnknownScansPause time.Duration FetchAllScansPause time.Duration GetMetricsPause time.Duration LoginPause time.Duration RefreshScanThreshold time.Duration }
Timings ...
type Version ¶
type Version struct { CodeLocations []CodeLocation RiskProfile RiskProfile PolicyStatus PolicyStatus Distribution string Nickname string VersionName string ReleasedOn string ReleaseComments string Phase string }
Version .....