Repository navigation
fix(dotnet): resolve packages.lock dependencies deterministically - #5210
Conversation
…ramework Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
… target frameworks Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
ac8570f to
c60cb64
Compare
CAOShurong
left a comment
There was a problem hiding this comment.
End-to-end verification on the current head (c60cb64), Windows, syft built from the exact head with the issue's multi-target scenario (Newtonsoft.Json Direct under net8.0 / Transitive under netstandard2.0, Serilog pulled transitively via MyLogAdapter):
- determinism, 100 scans of the same fixture: main flips (88 Direct / 12 Transitive), this head is 100/100 "Direct" — the reported nondeterminism is gone and Direct-wins is stable;
- relationships resolve per-framework correctly and dedupe across frameworks: the fixture yields exactly one "Serilog dependency-of MyLogAdapter" edge, and Serilog itself is reported Transitive as every framework sees it;
- package order and relationship order are stable across runs.
One scope note (matches what the PR already implies): metadata.requested from the lockfile is still not surfaced (metadata exposes name/version/type/contentHash only), so the second observation in #5211 remains open beyond this PR — worth a tracking note so it isn't lost when this merges.
|
Independent end-to-end verification of #5210 (maintainer fix for #5211), run 2026-08-24 ~02:20+08:00. Setup
Baseline (main): nondeterminism confirmed on Windows too 60 scans of the byte-identical input:
This reproduces the issue's flip-rate (~17% here vs ~16% in the issue) outside Linux, so the randomized-map-order root cause is platform-independent. Also confirmed on main: Candidate (#5210 head c60cb64): deterministic Same loop, same machine: 60/60 runs → Tests
One observation, not a blocker The fix resolves the determinism and Direct-preference halves of the issue cleanly. The lossiness half remains open by design: after stabilization the SBOM reports only Nice-to-have if you want belt-and-suspenders coverage: a test asserting that two parses of the multi-framework fixture produce identical package metadata ordering, which would catch any future regression into map-order dependence even before golden-file comparison. Verified as an independent third party; no code changes proposed — the PR looks correct and ready from this side. |
* main: (91 commits) feat: catalog CPAN distributions installed by perl clients (#5131) fix(binary): correct traefik version detection on big-endian arches (#5281) Fix hang when scanning a Java resource adapter (.rar) file (#5348) chore(deps): update SPDX license list (#5315) fix: match opensource.org license URLs across SPDX URL forms (#5361) Speed up unit tests in CI (#5360) Fix missing file hashes when running on windows system (#5341) Stop reading the mount table for every single-file source (#5257) fix: conan expat CPE (#5259) fix(spdx): write a name for the root package when the source has none (#5349) fix(python): link uv.lock dependents to the locked version they name (#5351) fix: suppress misleading upstream CPE for PHP extension binaries (#5102) fix: report scanner errors and raise the line cap in metadata parsers (#5353) Harden cataloger parsers against truncated input (do not panic) (#5355) fix(cpe): bound CPE candidate generation for pathological package metadata (#5356) test(golang): make the UPX fixture exercise loader padding (#5354) fix(golang): account for UPX's loader padding when unpacking Go binaries (#5347) test(snap): bound the kernel changelog bomb fixture by ratio, not a fixed 1MB (#5352) test(debian): bound the bomb fixture by ratio, not a fixed 1MB (#5350) fix(ai): handle malformed GGUF headers without panicking (#5345) ...
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
NuGet IDs are case-insensitive, and edge lookup already treated them that way, but package identity used the exact-case name. Two spellings of one ID and version across target frameworks became two packages, and type precedence never ran between them. - packages merge on the lowercased name + version, display name comes from the winning entry - a package listing itself (under any casing) no longer produces a self edge Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Description
packages.lock.jsoncan group packages by target framework.The parser flattened those groups when it ranged over Go maps.
For multi-targeted projects the SBOM depended on map iteration order causing document instability.
Changes
by name. Packages and relationships are both derived from it.
Project>Direct>CentralTransitive>Transitive(unknown types last).Runtime-specific sections (
net8.0/win-x64) fall back to their base framework. Unresolvableedges are dropped with a debug log instead of guessed from another framework.
Not in scope (remains open in #5211)
requestedis not captured.Testing
TestParseDotnetPackagesLock_multipleTargetFrameworks: per-framework version resolution,Direct-wins, and cross-framework edge dedup
Test_findDependencyPkg: resolution precedence and the lowest-version fallbackRefs #5211. Follow-up to #5143.