Add --vulnerable to dotnet package update#6768
Merged
Conversation
martinrrm
reviewed
Sep 8, 2025
src/NuGet.Core/NuGet.CommandLine.XPlat/Utility/MSBuildAPIUtility.cs
Outdated
Show resolved
Hide resolved
b22300f to
6df1d9e
Compare
nkolev92
reviewed
Sep 9, 2025
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateIO.cs
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/VersionChooser.cs
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/VersionChooser.cs
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs
Show resolved
Hide resolved
aortiz-msft
requested changes
Sep 9, 2025
Contributor
aortiz-msft
left a comment
There was a problem hiding this comment.
Since the command will only work with NuGetAudit enabled and only at the level at which it is configured, could we add output clarifying the behavior?
For example, when NuGetAudit is disabled for the repo, print "NuGetAudit is disabled for this repo so this command will now exit.
When NuGetAuditMode = direct, print "NuGet Audit is configured to only look at direct dependencies, so this command will ignore vulnerable transitive dependencies."
aortiz-msft
reviewed
Sep 11, 2025
aortiz-msft
reviewed
Sep 11, 2025
...ne.Xplat.Tests/Commands/Package/Update/PackageUpdateCommandRunnerTests/SingleProjectTests.cs
Outdated
Show resolved
Hide resolved
aortiz-msft
approved these changes
Sep 11, 2025
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#13372
Description
Adds
--vulnerabletodotnet package update.This PR deviates from the feature spec because during implementation it was a bit easier (and therefore quicker). But I was also thinking one of the primary use cases for this command will be to fix warnings reported during restore. So, instead of having a
--modeor similar, it looks at the restore results, and fixes the packages reported by restore. This has the benefit of respecting the project's direct only or direct + transitive NuGetAuditMode setting.I created this issue to track supporting updating vulnerable packages when audit is disabled: NuGet/Home#14526
Here's sample output when the command works successfully:

Here's an example where attempting to upgrade introduces a restore error:

We can see it output all the packages, and versions, that it attempted to upgrade, as well as the restore error message. This gives the customer enough information to upgrade packages one by one, and know which versions no longer have any security advisories.
Additionally, some changes to the code shared with
dotnet package addwas modified so that when a transitive package specific to a subset of project TFMs needs to be added, it puts the correct condition on the package reference.PR Checklist
Added testsnot enough time at the moment, but a tracking issue is created: Improve tests fordotnet package update --vulnerableHome#14525