Skip to content

Commit

Permalink
Merge pull request #51 from mostlikelee/sofa-url-column
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert authored May 30, 2024
2 parents 1c2c38c + 5861548 commit 05bb974
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tables/sofa/sofa_cves.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func SofaUnpatchedCVEsColumns() []table.ColumnDefinition {
table.TextColumn("cve"),
table.TextColumn("patched_version"),
table.TextColumn("actively_exploited"),
table.TextColumn("url"),
}
}

Expand Down Expand Up @@ -90,6 +91,7 @@ func SofaUnpatchedCVEsGenerate(ctx context.Context, queryContext table.QueryCont
"cve": unpatchedCVE.CVE,
"patched_version": unpatchedCVE.PatchedVersion,
"actively_exploited": strconv.FormatBool(unpatchedCVE.ActivelyExploited),
"url": url,
})
}

Expand Down
6 changes: 4 additions & 2 deletions tables/sofa/sofa_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func SofaSecurityReleaseInfoColumns() []table.ColumnDefinition {
table.IntegerColumn("unique_cves_count"),
table.IntegerColumn("days_since_previous_release"),
table.TextColumn("os_version"),
table.TextColumn("url"),
}
}

Expand Down Expand Up @@ -168,10 +169,10 @@ func SofaSecurityReleaseInfoGenerate(ctx context.Context, queryContext table.Que
return nil, err
}

return buildSecurityReleaseInfoOutput(securityReleases, osVersion), nil
return buildSecurityReleaseInfoOutput(securityReleases, osVersion, url), nil
}

func buildSecurityReleaseInfoOutput(securityReleases []SecurityRelease, osVersion string) []map[string]string {
func buildSecurityReleaseInfoOutput(securityReleases []SecurityRelease, osVersion, url string) []map[string]string {
var results []map[string]string
for _, securityRelease := range securityReleases {
results = append(results, map[string]string{
Expand All @@ -182,6 +183,7 @@ func buildSecurityReleaseInfoOutput(securityReleases []SecurityRelease, osVersio
"unique_cves_count": strconv.Itoa(securityRelease.UniqueCVEsCount),
"days_since_previous_release": strconv.Itoa(securityRelease.DaysSincePreviousRelease),
"os_version": osVersion,
"url": url,
})
}
return results
Expand Down
3 changes: 2 additions & 1 deletion tables/sofa/sofa_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ func TestBuildSecurityReleaseInfoOutput(t *testing.T) {
"unique_cves_count": "3",
"days_since_previous_release": "30",
"os_version": "14.5.1",
"url": SofaV1URL,
},
}

output := buildSecurityReleaseInfoOutput(securityReleases, osVersion)
output := buildSecurityReleaseInfoOutput(securityReleases, osVersion, SofaV1URL)

assert.Equal(t, expectedOutput, output)
}

0 comments on commit 05bb974

Please sign in to comment.