Skip to content

Commit

Permalink
Harmonize CVEToPackageInfo and CVEToOSV
Browse files Browse the repository at this point in the history
Order the work so it's only done if necessary, and add the previous edge
case fix to CVEToOSV as well.
  • Loading branch information
andrewpollock committed May 15, 2024
1 parent 8c521a6 commit f6e8c4d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vulnfeeds/cmd/nvd-cve-osv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func CVEToOSV(CVE cves.CVE, repos []string, cache git.RepoTagsCache, directory s
}
}

if versions.HasLastAffectedVersions() && !hasAnyLastAffectedCommits {
if versions.HasLastAffectedVersions() && !hasAnyLastAffectedCommits && !hasAnyFixedCommits {
return fmt.Errorf("[%s]: Failed to convert last_affected version tags to commits: %#v %w", CVE.ID, versions, ErrUnresolvedFix)
}
}
Expand Down Expand Up @@ -372,17 +372,17 @@ func CVEToPackageInfo(CVE cves.CVE, repos []string, cache git.RepoTagsCache, dir
}
}

if versions.HasFixedVersions() && !hasAnyFixedCommits {
return fmt.Errorf("[%s]: Failed to convert fixed version tags to commits: %#v %w", CVE.ID, versions, ErrUnresolvedFix)
}

hasAnyLastAffectedCommits := false
for _, repo := range repos {
if versions.HasLastAffectedCommits(repo) {
hasAnyLastAffectedCommits = true
}
}

if versions.HasFixedVersions() && !hasAnyFixedCommits {
return fmt.Errorf("[%s]: Failed to convert fixed version tags to commits: %#v %w", CVE.ID, versions, ErrUnresolvedFix)
}

if versions.HasLastAffectedVersions() && !hasAnyLastAffectedCommits && !hasAnyFixedCommits {
return fmt.Errorf("[%s]: Failed to convert last_affected version tags to commits: %#v %w", CVE.ID, versions, ErrUnresolvedFix)
}
Expand Down

0 comments on commit f6e8c4d

Please sign in to comment.