Skip to content

Commit

Permalink
added remediation
Browse files Browse the repository at this point in the history
  • Loading branch information
tandr committed Dec 6, 2019
1 parent cb44460 commit 879a897
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions hubapi/component-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,17 @@ type ComponentRequest struct {
ApprovalStatus string `json:"approvalStatus"`
Type string `json:"type"`
}

type ComponentRemediation struct {
FixesPreviousVulnerabilities *RemediationInfo `json:"fixesPreviousVulnerabilities,omitempty"`
NoVulnerabilities *RemediationInfo `json:"noVulnerabilities,omitempty"`
LatestAfterCurrent *RemediationInfo `json:"latestAfterCurrent,omitempty"`
Meta Meta `json:"_meta"`
}

type RemediationInfo struct {
Name string `json:"name"`
ComponentVersion string `json:"componentVersion"`
ReleasedOn time.Time `json:"releasedOn"`
VulnerabilityCount int `json:"vulnerabilityCount"`
}
17 changes: 16 additions & 1 deletion hubclient/component-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import (
log "github.com/sirupsen/logrus"
)

const apiComponents = "/api/components"
const (
apiComponents = "/api/components"
remediatingApi = "/remediating"
)

func (c *Client) ListComponents(options *hubapi.GetListOptions) (*hubapi.ComponentList, error) {
componentURL := c.baseURL + apiComponents
Expand Down Expand Up @@ -96,3 +99,15 @@ func (c *Client) GetComponentVersion(link hubapi.ResourceLink) (*hubapi.Componen

return &componentVersion, nil
}

func (c *Client) GetComponentVersionRemediation(componentVersionHref string) (*hubapi.ComponentRemediation, error) {
var componentRemediation hubapi.ComponentRemediation

err := c.HttpGetJSON(componentVersionHref+remediatingApi, &componentRemediation, 200)

if err != nil {
return nil, AnnotateHubClientError(err, "Error trying to retrieve component remediation advice")
}

return &componentRemediation, nil
}

0 comments on commit 879a897

Please sign in to comment.