mirror of
https://github.com/safedep/vet.git
synced 2025-12-10 00:22:08 -06:00
fix: #180 Ensure version update is available before proposing in summary reporter
This commit is contained in:
parent
bd743347d0
commit
b08c8a4581
@ -329,12 +329,10 @@ func (r *summaryReporter) renderRemediationAdvice() {
|
||||
break
|
||||
}
|
||||
|
||||
insight := utils.SafelyGetValue(sp.pkg.Insights)
|
||||
|
||||
tbl.AppendRow(table.Row{
|
||||
string(sp.pkg.Ecosystem),
|
||||
r.packageNameForRemediationAdvice(sp.pkg),
|
||||
utils.SafelyGetValue(insight.PackageCurrentVersion),
|
||||
r.packageUpdateVersionForRemediationAdvice(sp.pkg),
|
||||
sp.score,
|
||||
})
|
||||
|
||||
@ -368,6 +366,22 @@ func (r *summaryReporter) packageNameForRemediationAdvice(pkg *models.Package) s
|
||||
pkg.PackageDetails.Version)
|
||||
}
|
||||
|
||||
func (r *summaryReporter) packageUpdateVersionForRemediationAdvice(pkg *models.Package) string {
|
||||
insight := utils.SafelyGetValue(pkg.Insights)
|
||||
insightsCurrentVersion := utils.SafelyGetValue(insight.PackageCurrentVersion)
|
||||
|
||||
if insightsCurrentVersion == "" {
|
||||
return "Not Available"
|
||||
}
|
||||
|
||||
sver, _ := semver.Diff(pkg.PackageDetails.Version, insightsCurrentVersion)
|
||||
if sver.IsNone() {
|
||||
return "-"
|
||||
}
|
||||
|
||||
return insightsCurrentVersion
|
||||
}
|
||||
|
||||
func (r *summaryReporter) vulnSummaryStatement() string {
|
||||
return fmt.Sprintf("%d critical, %d high and %d other vulnerabilities were identified",
|
||||
r.summary.vulns.critical, r.summary.vulns.high,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user