Skip to content

Fix deterministic ordering for multiple package versions with lockfiles#99

Merged
piloulacdog merged 5 commits intomainfrom
pierrelouis.lacorte/fix-deterministic-order
Jan 23, 2026
Merged

Fix deterministic ordering for multiple package versions with lockfiles#99
piloulacdog merged 5 commits intomainfrom
pierrelouis.lacorte/fix-deterministic-order

Conversation

@piloulacdog
Copy link
Copy Markdown
Contributor

@piloulacdog piloulacdog commented Jan 22, 2026

🚀 Motivation

Identified an issue when running consistency check for our running on a nuget package: https://github.com/DataDog/software-composition-analysis-test/actions/runs/21254063506

When NuGet projects use lockfiles with multiple target frameworks that reference different versions of the same package, the SBOM generator was producing non-deterministic results. This occurred because the package matching logic used only package names as keys, causing unpredictable behavior when multiple versions existed. This non-determinism makes SBOMs unreliable and difficult to compare across builds.

The fix ensures that when the same package+version appears multiple times (e.g., in different conditional ItemGroups), we consistently pick the first occurrence by line number, making the output deterministic and reproducible.

🧪 Testing

  • New tests were added for new logic.
  • Existing tests were updated for new logic, and not only so that they pass!
  • Benchmark results prove that performance is the same or better.

@piloulacdog piloulacdog marked this pull request as ready for review January 22, 2026 17:36
@piloulacdog piloulacdog requested a review from a team as a code owner January 22, 2026 17:36
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 22, 2026

Go test coverage report

Total test coverage: 90.5% (4352/4807)

Test coverage has changed in the current files, with 1 lines missing coverage.
file: uncovered: current coverage: base coverage:
pkg/lockfile/dotnet/match-nuget-csproj.go 1 97.1% (33/34) 91.3% (21/23)

@rjcoulter22 rjcoulter22 self-requested a review January 23, 2026 16:48
@piloulacdog piloulacdog merged commit c3b017e into main Jan 23, 2026
10 checks passed
@piloulacdog piloulacdog deleted the pierrelouis.lacorte/fix-deterministic-order branch January 23, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants