Fix mis-interpretation of severity in Clair

Currently "Critical" vulnerablity is treated as "Unknown" in Harbor.
This commit provides a quickfix that it will be interpret as "High".  In
future, we should consider introduce "Critical" and enable UI to handle
it to be more consistent with CVSS spec.
This commit is contained in:
Tan Jiang 2018-04-25 10:31:12 +08:00
parent 5089b26cf8
commit 93c448d91b
3 changed files with 4 additions and 2 deletions

View File

@ -29,6 +29,7 @@ const (
SeverityLow = "low" SeverityLow = "low"
SeverityMedium = "medium" SeverityMedium = "medium"
SeverityHigh = "high" SeverityHigh = "high"
SeverityCritical = "critical"
) )
// ProjectMetadata holds the metadata of a project. // ProjectMetadata holds the metadata of a project.

View File

@ -15,10 +15,10 @@
package clair package clair
import ( import (
"fmt"
"github.com/vmware/harbor/src/common/dao" "github.com/vmware/harbor/src/common/dao"
"github.com/vmware/harbor/src/common/models" "github.com/vmware/harbor/src/common/models"
"github.com/vmware/harbor/src/common/utils/log" "github.com/vmware/harbor/src/common/utils/log"
"fmt"
"strings" "strings"
) )
@ -34,7 +34,7 @@ func ParseClairSev(clairSev string) models.Severity {
return models.SevLow return models.SevLow
case models.SeverityMedium: case models.SeverityMedium:
return models.SevMedium return models.SevMedium
case models.SeverityHigh: case models.SeverityHigh, models.SeverityCritical:
return models.SevHigh return models.SevHigh
default: default:
return models.SevUnknown return models.SevUnknown

View File

@ -32,6 +32,7 @@ func TestParseServerity(t *testing.T) {
"LOW": models.SevLow, "LOW": models.SevLow,
"Medium": models.SevMedium, "Medium": models.SevMedium,
"high": models.SevHigh, "high": models.SevHigh,
"Critical": models.SevHigh,
} }
for k, v := range in { for k, v := range in {
assert.Equal(v, ParseClairSev(k)) assert.Equal(v, ParseClairSev(k))