fix(dotnet): preserve requested version range in packages.lock.json metadata (#5211) - #5220
Open
CAOShurong wants to merge 1 commit into
Open
fix(dotnet): preserve requested version range in packages.lock.json metadata (#5211)#5220CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
…etadata The packages.lock.json parser dropped the 'requested' field entirely, so downstream consumers lose the original version-range constraint (e.g. '[13.0.3, )') that the project declared. Add Requested to the DotnetPackagesLockEntry struct (json 'requested', omitempty so Transitive entries with no requested value stay clean) and populate it from the parsed dependency. Extends the existing TestParseDotnetPackagesLock golden package expectations with the resolved requested ranges. This closes the lossiness half of anchore#5211 (the determinism and Direct-preference halves are handled separately in anchore#5210). Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
packages.lock.jsonparser dropped therequestedfield entirely, so downstream consumers lose the original version-range constraint (e.g.[13.0.3, )) that the project declared in its lockfile.This PR:
Requestedto theDotnetPackagesLockEntrystruct (json:"requested,omitempty"—omitemptykeepsTransitiveentries that declare norequestedvalue clean).newDotnetPackagesLockPackage.TestParseDotnetPackagesLockgolden package expectations with the resolvedrequestedranges.This closes the lossiness half of #5211. The determinism and Direct-preference halves are handled separately in #5210 (maintainer fix), which I independently verified in round rev 79. This change is orthogonal and stacks cleanly on top of it.
Verification
go test ./syft/pkg/cataloger/dotnet/ -run TestParseDotnetPackagesLock -count=10→ PASS (alsogo vetclean).End-to-end on a byte-identical
packages.lock.jsonfixture whereNewtonsoft.Jsonis declaredDirectwithrequested: "[13.0.3, )":Before this change,
requestedwas absent.The other dotnet-cataloger tests that shell out to
dockerfail in this environment for lack of a Docker daemon — they are unrelated to this change and fail identically on unmodifiedmain.Checklist
TestParseDotnetPackagesLockexpectations now assertRequested).Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>).Relates to #5211.
🤖 Generated with Claude Code