Skip to content

Commit

Permalink
fix: fix vuln ctr fail_on_severity (#1048)
Browse files Browse the repository at this point in the history
* fix: fix vuln ctr fail_on_severity
  • Loading branch information
dmurray-lacework authored Dec 5, 2022
1 parent b1e7b28 commit dcf79d3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions api/v2_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"strconv"
"strings"
"time"

"github.com/lacework/go-sdk/lwseverity"
)

// v2VulnerabilitiesService is a service that interacts with the Vulnerabilities
Expand Down Expand Up @@ -175,20 +177,18 @@ type VulnerabilitiesContainersResponse struct {
}

func (r VulnerabilitiesContainersResponse) HighestSeverity() string {
var (
sevs []int
max int
)
var sevs []lwseverity.Severity

for _, vuln := range r.Data {
sevs = append(sevs, SeverityOrder(vuln.Severity))
if len(sevs) == 1 {
max = SeverityOrder(vuln.Severity)
} else if SeverityOrder(vuln.Severity) > max {
max = SeverityOrder(vuln.Severity)
}
sevs = append(sevs, lwseverity.NewSeverity(vuln.Severity))
}

return SeverityInt(max)
if len(sevs) == 0 {
return lwseverity.Unknown.String()
}

lwseverity.SortSlice(sevs)
return sevs[0].GetSeverity()
}

func (r VulnerabilitiesContainersResponse) HighestFixableSeverity() string {
Expand Down

0 comments on commit dcf79d3

Please sign in to comment.