Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
- ecr: surface cvss score & description field.
Browse files Browse the repository at this point in the history
  • Loading branch information
gadinaor committed Oct 24, 2020
1 parent 8fc3e0e commit dc92d0d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pkg/vulnprovider/ecr/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/kylelemons/godebug/pretty"
"os"
"strconv"
"strings"

"github.com/alcideio/iskan/pkg/types"
Expand Down Expand Up @@ -102,11 +103,12 @@ func getImageScanFindings(ecrclient ecrClient, containerImage string) ([]*grafea
ecrRegion := hostPart[3]

image := strings.TrimPrefix(repo, "/")
awsRepoName := strings.SplitAfterN(repo, "/", 2)
awsRepoName := strings.Split(repo, "/")
awsRepo := strings.Join(awsRepoName[1:], "/")

input := &ecr.DescribeImageScanFindingsInput{
RegistryId: aws.String(ecrAccount),
RepositoryName: aws.String(awsRepoName[1]),
RepositoryName: aws.String(awsRepo),
ImageId: &ecr.ImageIdentifier{},
}

Expand Down Expand Up @@ -162,23 +164,32 @@ func getFindings(findings []*ecr.ImageScanFinding, ecrAccount string, ecrRegion

for _, p := range findings {
var packageURI, packageName, packageVersion string
var cvss2Score float32

packageSeverity := getVulnerabilitySeverity(*p.Severity)

//FIXME
for _, k := range p.Attributes {
if *k.Key == "package_name" {
switch *k.Key {
case "package_name":
packageName = *k.Value
} else if *k.Key == "package_version" {
case "package_version":
packageVersion = *k.Value
//case "CVSS2_VECTOR":
// cvss2vector = *k.Value
case "CVSS2_SCORE":
score, _ := strconv.ParseFloat(*k.Value, 32)
cvss2Score = float32(score)
}
}

packageURI = *p.Uri

v := &grafeas.Occurrence_Vulnerability{
Vulnerability: &grafeas.VulnerabilityOccurrence{
Severity: packageSeverity,
Severity: packageSeverity,
LongDescription: aws.StringValue(p.Description),
CvssScore: cvss2Score,
PackageIssue: []*grafeas.VulnerabilityOccurrence_PackageIssue{
{
AffectedCpeUri: packageURI,
Expand Down

0 comments on commit dc92d0d

Please sign in to comment.