Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Aug 30, 2023
1 parent b161d9e commit d75f3bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions xray/utils/analyzermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
type SarifLevel string

const (
Err SarifLevel = "error"
Error SarifLevel = "error"
Warning SarifLevel = "warning"
Info SarifLevel = "info"
Note SarifLevel = "note"
Expand All @@ -34,9 +34,9 @@ const (
var (
// All other values (include default) mapped as 'Medium' severity
levelToSeverity = map[SarifLevel]string{
Err: "High",
Note: "Low",
None: "Unknown",
Error: "High",
Note: "Low",
None: "Unknown",
}
)

Expand Down Expand Up @@ -248,7 +248,7 @@ func ExtractRelativePath(resultPath string, projectRoot string) string {

func GetResultSeverity(result *sarif.Result) string {
if result.Level != nil {
if severity, ok := levelToSeverity[SarifLevel(*result.Level)]; ok {
if severity, ok := levelToSeverity[SarifLevel(strings.ToLower(*result.Level))]; ok {
return severity
}
}
Expand Down
7 changes: 4 additions & 3 deletions xray/utils/analyzermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package utils
import (
"errors"
"fmt"
"path/filepath"
"testing"

"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/owenrumney/go-sarif/v2/sarif"
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"
)

func TestRemoveDuplicateValues(t *testing.T) {
Expand Down Expand Up @@ -115,7 +116,7 @@ func TestExtractRelativePath(t *testing.T) {
}

func TestGetResultSeverity(t *testing.T) {
levelValueHigh := string(Err)
levelValueHigh := string(Error)
levelValueMedium := string(Warning)
levelValueMedium2 := string(Info)
levelValueLow := string(Note)
Expand Down

0 comments on commit d75f3bf

Please sign in to comment.