Documentation
¶
Index ¶
- func MinDuration(left time.Duration, right time.Duration) time.Duration
- type CircuitBreaker
- type CircuitBreakerState
- type Client
- func (hub *Client) FinishScanClient(scanName string, scanErr error)
- func (hub *Client) HasFetchedScans() <-chan bool
- func (hub *Client) Host() string
- func (hub *Client) InProgressScans() <-chan []string
- func (hub *Client) Model() <-chan *api.ModelHub
- func (hub *Client) ResetCircuitBreaker()
- func (hub *Client) ScanResults() <-chan map[string]*Scan
- func (hub *Client) ScansCount() <-chan int
- func (hub *Client) SetTimeout(timeout time.Duration)
- func (hub *Client) StartScanClient(scanName string)
- func (hub *Client) Stop()
- func (hub *Client) StopCh() <-chan struct{}
- func (hub *Client) Updates() <-chan Update
- func (hub *Client) Version() (string, error)
- type ClientInterface
- type ClientStatus
- type CodeLocation
- type DidFindScan
- type DidFinishScan
- type DidRefreshScan
- 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 PolicyStatus
- type PolicyStatusType
- type Project
- type RawClientInterface
- type Result
- type RiskProfile
- type RiskProfileCategory
- type RiskProfileStatus
- type RiskProfileStatusCounts
- type Scan
- type ScanResults
- type ScanStage
- type ScanSummary
- type ScanSummaryStatus
- type Update
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 .....
func NewClient ¶
func NewClient(username string, password string, host string, client RawClientInterface, scanCompletionPause time.Duration, fetchUnknownScansPause time.Duration, fetchAllScansPause time.Duration) *Client
NewClient returns a new Client. It will not be logged in.
func (*Client) FinishScanClient ¶
FinishScanClient ...
func (*Client) HasFetchedScans ¶
HasFetchedScans ...
func (*Client) InProgressScans ¶
InProgressScans ...
func (*Client) ResetCircuitBreaker ¶
func (hub *Client) ResetCircuitBreaker()
ResetCircuitBreaker ...
func (*Client) ScanResults ¶
ScanResults ...
func (*Client) SetTimeout ¶
SetTimeout is currently not concurrent-safe, and should be made so TODO
func (*Client) StartScanClient ¶
StartScanClient ...
func (*Client) StopCh ¶
func (hub *Client) StopCh() <-chan struct{}
StopCh returns a reference to the stop channel
type ClientInterface ¶
type ClientInterface interface {
// commands coming in
StartScanClient(scanName string)
FinishScanClient(scanName string, scanErr error)
SetTimeout(timeout time.Duration)
ResetCircuitBreaker()
// read-only queries
Host() string
Version() (string, error)
// read-only, async queries (the channel produces a single event)
Model() <-chan *api.ModelHub
HasFetchedScans() <-chan bool
ScansCount() <-chan int
InProgressScans() <-chan []string
ScanResults() <-chan map[string]*Scan
Updates() <-chan Update
// prelude to clean-up
Stop()
StopCh() <-chan struct{}
}
ClientInterface .....
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 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 PolicyStatus ¶
type PolicyStatus struct {
OverallStatus PolicyStatusType
UpdatedAt string
ComponentVersionStatusCounts map[PolicyStatusType]int
}
PolicyStatus .....
func (*PolicyStatus) ViolationCount ¶
func (ps *PolicyStatus) ViolationCount() int
ViolationCount .....
type PolicyStatusType ¶ added in v0.0.8
type PolicyStatusType int
PolicyStatusType .....
const ( PolicyStatusTypeNotInViolation PolicyStatusType = iota PolicyStatusTypeInViolation PolicyStatusType = iota PolicyStatusTypeInViolationOverridden PolicyStatusType = iota )
.....
func (PolicyStatusType) MarshalJSON ¶ added in v0.0.8
func (p PolicyStatusType) MarshalJSON() ([]byte, error)
MarshalJSON .....
func (PolicyStatusType) MarshalText ¶ added in v0.0.8
func (p PolicyStatusType) MarshalText() (text []byte, err error)
MarshalText .....
func (PolicyStatusType) String ¶ added in v0.0.8
func (p PolicyStatusType) String() string
String .....
func (*PolicyStatusType) UnmarshalText ¶ added in v0.0.18
func (p *PolicyStatusType) UnmarshalText(text []byte) (err error)
UnmarshalText .....
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 Result ¶
type Result struct {
Value interface{}
Err error
}
Result models computations that may succeed or fail.
type RiskProfile ¶
type RiskProfile struct {
Categories map[RiskProfileCategory]RiskProfileStatusCounts
BomLastUpdatedAt string
}
RiskProfile .....
func (*RiskProfile) HighRiskVulnerabilityCount ¶
func (rp *RiskProfile) HighRiskVulnerabilityCount() int
HighRiskVulnerabilityCount .....
type RiskProfileCategory ¶ added in v0.0.8
type RiskProfileCategory int
RiskProfileCategory .....
const ( RiskProfileCategoryActivity RiskProfileCategory = iota RiskProfileCategoryLicense RiskProfileCategory = iota RiskProfileCategoryOperational RiskProfileCategory = iota RiskProfileCategoryVersion RiskProfileCategory = iota RiskProfileCategoryVulnerability RiskProfileCategory = iota )
.....
func (RiskProfileCategory) MarshalText ¶ added in v0.0.8
func (r RiskProfileCategory) MarshalText() (text []byte, err error)
MarshalText .....
func (RiskProfileCategory) String ¶ added in v0.0.8
func (r RiskProfileCategory) String() string
String .....
func (*RiskProfileCategory) UnmarshalJSON ¶ added in v0.0.18
func (r *RiskProfileCategory) UnmarshalJSON(data []byte) error
UnmarshalJSON .....
func (*RiskProfileCategory) UnmarshalText ¶ added in v0.0.18
func (r *RiskProfileCategory) UnmarshalText(text []byte) (err error)
UnmarshalText .....
type RiskProfileStatus ¶ added in v0.0.8
type RiskProfileStatus int
RiskProfileStatus .....
const ( RiskProfileStatusHigh RiskProfileStatus = iota RiskProfileStatusMedium RiskProfileStatus = iota RiskProfileStatusLow RiskProfileStatus = iota RiskProfileStatusOK RiskProfileStatus = iota RiskProfileStatusUnknown RiskProfileStatus = iota )
.....
func (RiskProfileStatus) MarshalJSON ¶ added in v0.0.8
func (r RiskProfileStatus) MarshalJSON() ([]byte, error)
MarshalJSON .....
func (RiskProfileStatus) MarshalText ¶ added in v0.0.8
func (r RiskProfileStatus) MarshalText() (text []byte, err error)
MarshalText .....
func (RiskProfileStatus) String ¶ added in v0.0.8
func (r RiskProfileStatus) String() string
String .....
func (*RiskProfileStatus) UnmarshalJSON ¶ added in v0.0.18
func (r *RiskProfileStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON .....
func (*RiskProfileStatus) UnmarshalText ¶ added in v0.0.18
func (r *RiskProfileStatus) UnmarshalText(text []byte) (err error)
UnmarshalText .....
type RiskProfileStatusCounts ¶ added in v0.0.8
type RiskProfileStatusCounts struct {
StatusCounts map[RiskProfileStatus]int
}
RiskProfileStatusCounts .....
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() PolicyStatusType
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 Version ¶
type Version struct {
CodeLocations []CodeLocation
RiskProfile RiskProfile
PolicyStatus PolicyStatus
Distribution string
Nickname string
VersionName string
ReleasedOn string
ReleaseComments string
Phase string
}
Version .....