Skip to content

Commit

Permalink
Merge pull request #3582 from ActiveState/mitchell/dx-3150
Browse files Browse the repository at this point in the history
CVE report should include changed requirements.
  • Loading branch information
mitchell-as authored Nov 7, 2024
2 parents 0100fab + 110c0db commit 4e15f20
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/runbits/cves/cves.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *CveReport) Report(newBuildPlan *buildplan.BuildPlan, oldBuildPlan *buil
}
}

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

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

func addedRequirements(oldBuildPlan *buildplan.BuildPlan, newBuildPlan *buildplan.BuildPlan) []string {
func changedRequirements(oldBuildPlan *buildplan.BuildPlan, newBuildPlan *buildplan.BuildPlan) []string {
var names []string
var oldRequirements buildplan.Requirements
if oldBuildPlan != nil {
oldRequirements = oldBuildPlan.Requirements()
}
newRequirements := newBuildPlan.Requirements()

oldReqs := make(map[string]bool)
oldReqs := make(map[string]string)
for _, req := range oldRequirements {
oldReqs[qualifiedName(req)] = true
oldReqs[qualifiedName(req)] = req.Ingredient.Version
}

for _, req := range newRequirements {
if oldReqs[qualifiedName(req)] || req.Namespace == buildplan.NamespaceInternal {
if req.Namespace == buildplan.NamespaceInternal {
continue
}
if version, exists := oldReqs[qualifiedName(req)]; exists && version == req.Ingredient.Version {
continue
}
names = append(names, req.Name)
Expand Down

0 comments on commit 4e15f20

Please sign in to comment.