Skip to content

Commit

Permalink
refactor: code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paralta committed Nov 15, 2023
1 parent 982b78f commit bda6967
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
15 changes: 9 additions & 6 deletions pkg/shared/findingkey/exploit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@
package findingkey

import (
"fmt"
"crypto/sha256"

"github.com/openclarity/vmclarity/api/models"
)

type ExploitKey struct {
CveID string
SourceDB string
Urls *[]string
}

func (k ExploitKey) String() string {
return fmt.Sprintf("%s.%s", k.CveID, k.SourceDB)
hash := sha256.New()
for _, url := range *k.Urls {
hash.Write([]byte(url))
}

return string(hash.Sum(nil))
}

func GenerateExploitKey(exploit models.ExploitFindingInfo) ExploitKey {
return ExploitKey{
CveID: *exploit.CveID,
SourceDB: *exploit.SourceDB,
Urls: exploit.Urls,
}
}
4 changes: 3 additions & 1 deletion pkg/shared/findingkey/malware.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ import (
type MalwareKey struct {
MalwareName string
MalwareType string
RuleName string
}

func (k MalwareKey) String() string {
return fmt.Sprintf("%s.%s", k.MalwareName, k.MalwareType)
return fmt.Sprintf("%s.%s.%s", k.MalwareName, k.MalwareType, k.RuleName)
}

func GenerateMalwareKey(info models.MalwareFindingInfo) MalwareKey {
return MalwareKey{
MalwareName: utils.ValueOrZero(info.MalwareName),
MalwareType: utils.ValueOrZero(info.MalwareType),
RuleName: utils.ValueOrZero(info.RuleName),
}
}
5 changes: 3 additions & 2 deletions ui/src/layout/Dashboard/FindingsImpactWidget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ const TABS_COLUMNS_MAPPING = {
]
},
[FINDINGS_MAPPING.EXPLOITS.dataKey]: {
headerItems: ["Vulnerability name"],
headerItems: ["Vulnerability name", "URLs"],
bodyItems: [
{dataKey: "exploit.cveID"}
{dataKey: "exploit.cveID"},
{dataKey: "exploit.urls"}
]
},
[FINDINGS_MAPPING.MISCONFIGURATIONS.dataKey]: {
Expand Down

0 comments on commit bda6967

Please sign in to comment.