Skip to content

Commit 110c0db

Browse files
committed
CVE report should include changed requirements.
Previously it would only show for added requirements. If a requirement changes versions, we should include it in the CVE report.
1 parent 0100fab commit 110c0db

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

internal/runbits/cves/cves.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (c *CveReport) Report(newBuildPlan *buildplan.BuildPlan, oldBuildPlan *buil
7777
}
7878
}
7979

80-
names := addedRequirements(oldBuildPlan, newBuildPlan)
80+
names := changedRequirements(oldBuildPlan, newBuildPlan)
8181
pg := output.StartSpinner(c.prime.Output(), locale.Tr("progress_cve_search", strings.Join(names, ", ")), constants.TerminalAnimationInterval)
8282

8383
ingredientVulnerabilities, err := model.FetchVulnerabilitiesForIngredients(c.prime.Auth(), ingredients)
@@ -235,21 +235,24 @@ func (c *CveReport) promptForSecurity() (bool, error) {
235235
return confirm, nil
236236
}
237237

238-
func addedRequirements(oldBuildPlan *buildplan.BuildPlan, newBuildPlan *buildplan.BuildPlan) []string {
238+
func changedRequirements(oldBuildPlan *buildplan.BuildPlan, newBuildPlan *buildplan.BuildPlan) []string {
239239
var names []string
240240
var oldRequirements buildplan.Requirements
241241
if oldBuildPlan != nil {
242242
oldRequirements = oldBuildPlan.Requirements()
243243
}
244244
newRequirements := newBuildPlan.Requirements()
245245

246-
oldReqs := make(map[string]bool)
246+
oldReqs := make(map[string]string)
247247
for _, req := range oldRequirements {
248-
oldReqs[qualifiedName(req)] = true
248+
oldReqs[qualifiedName(req)] = req.Ingredient.Version
249249
}
250250

251251
for _, req := range newRequirements {
252-
if oldReqs[qualifiedName(req)] || req.Namespace == buildplan.NamespaceInternal {
252+
if req.Namespace == buildplan.NamespaceInternal {
253+
continue
254+
}
255+
if version, exists := oldReqs[qualifiedName(req)]; exists && version == req.Ingredient.Version {
253256
continue
254257
}
255258
names = append(names, req.Name)

0 commit comments

Comments
 (0)