-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .NET 9 breaking change about NuGetAuditMode changed default #43569
Open
zivkan
wants to merge
1
commit into
main
Choose a base branch
from
net9-nuget-breaking-change
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
docs/core/compatibility/sdk/9.0/nugetaudit-transitive-packages.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: "Breaking change: 'dotnet restore' produces security vulnerability warnings for transitive packages" | ||
description: Learn about a breaking change in the .NET 9 SDK where 'dotnet restore' produces security vulnerability warnings for transitive packages by default. | ||
--- | ||
# 'dotnet restore' produces security vulnerability warnings for transitive packages | ||
|
||
The [`dotnet restore` command](../../../tools/dotnet-restore.md), which restores the dependencies and tools of a project, now produces security vulnerability warnings for transitive packages by default. | ||
|
||
## Previous behavior | ||
|
||
In [.NET 8, we introduced NuGetAudit](../8.0/dotnet-restore-audit.md), which emits warnings for packages with known security vulnerabilities. | ||
It was possible to change the `NuGetAuditMode` property to include all packages, but the default was to report only direct package references. | ||
|
||
## New behavior | ||
|
||
`NuGetAuditMode` now defaults to `all`, if it has not been explicitly set. | ||
This means that transitive packages (dependencies of packages your project directly references) with known vulnerabilities will now cause warnings to be reported. | ||
If your project treats errors as warnings, this can cause restore failures. | ||
|
||
## Version introduced | ||
|
||
.NET 9 Preview 6 | ||
|
||
## Type of breaking change | ||
|
||
This change is a [behavioral change](../../categories.md#behavioral-change). | ||
|
||
## Reason for change | ||
|
||
Packages with known vulnerabilities might cause your app to be exploitable, even if your project does not directly reference or use the vulnerable package. | ||
New features in .NET 9 also make it easier to investigate the package graph, and suppress advisories that are not relevant to how your app uses the vulnerable package. | ||
|
||
## Recommended action | ||
|
||
- To explicitly reduce the probability of this breaking your build due to warnings, you can consider your usage of `<TreatWarningsAsErrors>` and use `<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>` to ensure known security vulnerabilities are still allowed in your environment. | ||
|
||
- Use tools, such as `dotnet nuget why`, to find the top-level package that caused the transitive package with the known vulnerability to be included, and try to upgrade it to see if the transitive vulnerability goes away. If not, promote the transitive package to a top-level package by adding a `PackageReference` for it, and upgrade it to a newer version. | ||
|
||
- If you want to suppress a specific advisory, you can add `<NuGetAuditSuppress Include="url" />` within an `<ItemGroup>`, where `url` is the URL reported in NuGet's warning message. | ||
|
||
- If you want to only be warned of direct package references with known vulnerabilities, you can set `<NuGetAuditMode>` to `direct`. | ||
|
||
## See also | ||
|
||
- [Audit for security vulnerabilities (`dotnet restore`)](../../../tools/dotnet-restore.md#audit-for-security-vulnerabilities) | ||
- [Auditing package dependencies for security vulnerabilities](/nuget/concepts/auditing-packages) | ||
- [NuGetAudit 2.0: Elevating Security and Trust in Package Management](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The blog seems to contain some information that the docs do not.
We should move all the content from the blog to some docs and reference those.
I recall someone else asking this as well, maybe we can create a tracking issue for that if there isn't one already.