Repository navigation
Allow string vuln severity in STJ code path - #7465
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses two System.Text.Json (STJ) deserialization issues in NuGet.Protocol when consuming nuget.org-style registration JSON: vulnerability severity occasionally arrives as a JSON string, and the STJ dependency-group converter could throw when skipping unknown properties in streaming scenarios.
Changes:
- Allow
PackageVulnerabilityMetadata.Severityto be read from a JSON string in the STJ path. - Update STJ
PackageDependencyGroupconverter to useUtf8JsonReader.TrySkip()instead ofSkip(). - Extend protocol tests/test data to validate vulnerability parsing (including severity-as-string) for both STJ and Newtonsoft.Json paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/TestUtilities/Test.Utility/JsonData.cs | Adds a vulnerability entry (with severity encoded as a string) to the DeepEqual registration test JSON. |
| test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageMetadataResourceV3Tests.cs | Asserts vulnerabilities are parsed correctly (severity + advisory URL) for both STJ-enabled and STJ-disabled runs. |
| src/NuGet.Core/NuGet.Protocol/Model/PackageVulnerabilityMetadata.cs | Enables STJ to read numeric severity from a JSON string via JsonNumberHandling.AllowReadingFromString. |
| src/NuGet.Core/NuGet.Protocol/Converters/PackageDependencyGroupStjConverter.cs | Switches unknown-property skipping to TrySkip() to avoid streaming-related exceptions. |
nkolev92
approved these changes
Jun 9, 2026
kartheekp-ms
approved these changes
Jun 9, 2026
This was referenced Jun 10, 2026
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.
Bug
Fixes: NuGet/Home#14938
Description
Fixes two bugs in the System.Text.Json deserialization path
PackageVulnerabilityMetadata.Severityis int. STJ rejects this by default.PackageDependencyGroupStjConvertercalledreader.Skip()which throws on streaming readers. Fix: use reader.TrySkip() instead.PR Checklist