Skip to content

Commit 844b737

Browse files
authored
fix: use the same sorting logic everywhere for sorting OSVs by their IDs (#1593)
I'm not sure if this ever actually matters, but I assume we want to always be using this function whenever we "sort OSVs by their IDs" for consistency
1 parent 95b1980 commit 844b737

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmd/osv-scanner/fix/noninteractive.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"deps.dev/util/resolve"
1111
"deps.dev/util/resolve/dep"
1212
"github.com/google/osv-scanner/v2/internal/datasource"
13+
"github.com/google/osv-scanner/v2/internal/identifiers"
1314
"github.com/google/osv-scanner/v2/internal/remediation"
1415
"github.com/google/osv-scanner/v2/internal/resolution"
1516
"github.com/google/osv-scanner/v2/internal/resolution/client"
@@ -408,7 +409,7 @@ func autoChooseOverridePatches(diffs []resolution.Difference, maxUpgrades int, o
408409

409410
func sortVulns(vulns []vulnOutput) {
410411
slices.SortFunc(vulns, func(a, b vulnOutput) int {
411-
return cmp.Compare(a.ID, b.ID)
412+
return identifiers.IDSortFunc(a.ID, b.ID)
412413
})
413414
}
414415

internal/output/output_result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ func getVulnList(vulnMap map[string]VulnResult) []VulnResult {
479479

480480
// Sort projectResults to ensure consistent output
481481
slices.SortFunc(vulnList, func(a, b VulnResult) int {
482-
return cmp.Compare(a.ID, b.ID)
482+
return identifiers.IDSortFunc(a.ID, b.ID)
483483
})
484484

485485
return vulnList

0 commit comments

Comments
 (0)