Skip to content

Add --vulnerable to dotnet package update#6768

Merged
zivkan merged 5 commits intodevfrom
dev-zivkan-update-vulnerable
Sep 11, 2025
Merged

Add --vulnerable to dotnet package update#6768
zivkan merged 5 commits intodevfrom
dev-zivkan-update-vulnerable

Conversation

@zivkan
Copy link
Member

@zivkan zivkan commented Sep 5, 2025

Bug

Fixes: NuGet/Home#13372

Description

Adds --vulnerable to dotnet 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 --mode or 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:
image

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

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 add was 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

@zivkan zivkan requested a review from martinrrm September 9, 2025 02:37
@zivkan zivkan force-pushed the dev-zivkan-update-vulnerable branch from b22300f to 6df1d9e Compare September 9, 2025 02:48
Copy link
Contributor

@aortiz-msft aortiz-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
aortiz-msft previously approved these changes Sep 11, 2025
Copy link
Contributor

@aortiz-msft aortiz-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@zivkan zivkan requested a review from aortiz-msft September 11, 2025 00:29
Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@zivkan zivkan merged commit d8af2ab into dev Sep 11, 2025
17 of 18 checks passed
@zivkan zivkan deleted the dev-zivkan-update-vulnerable branch September 11, 2025 05:16
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.

dotnet update package --vulnerable (Audit fix)

4 participants