You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/stale-issues.yml
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,9 @@ jobs:
26
26
close-issue-message: 'This issue is closed. If you feel this issue has been closed in error, please submit a new comment on the issue, and we will review it.'
Copy file name to clipboardExpand all lines: docs/concepts/Auditing-Packages.md
+16-40Lines changed: 16 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,10 @@ This involves identifying vulnerabilities, evaluating risks, and making recommen
16
16
The audit can include a review of the packages themselves, as well as any dependencies and their associated risks.
17
17
The goal of the audit is to identify and mitigate any security vulnerabilities that could be exploited by attackers, such as code injection or cross-site scripting attacks.
18
18
19
-
NuGet Audit is available starting from NuGet 6.8, the .NET 8 SDK (8.0.100), and Visual Studio 2022 17.8.
19
+
| Project Type | NuGet | .NET SDK | Visual Studio |
@@ -28,16 +31,8 @@ A description of your dependencies is checked against a report of known vulnerab
28
31
> NuGet.org's V3 URL is one such example (https://api.nuget.org/v3/index.json), but note that NuGet.org's V2 endpoint does not.
29
32
30
33
1. On the command line, navigate to your project or solution directory.
31
-
1. Ensure your project or solution contains a `.csproj` file.
32
-
1. Type `dotnet restore` or `restore` using your preferred tooling (i.e. MSBuild, NuGet.exe, etc).
33
-
1. Review the audit report and address the known security vulnerabilities.
34
-
35
-
> [!NOTE]
36
-
> At this time, NuGet does not audit `packages.config` projects.
37
-
38
-
## Reviewing and acting on the security audit report
39
-
40
-
Running `dotnet restore` will produce a report of security vulnerabilities with the affected package name, the severity of the vulnerability, and a link to the advisory for more details.
34
+
1. Run `restore` using your preferred tooling (i.e. dotnet, MSBuild, NuGet.exe, VisualStudio etc).
35
+
1. Review the warnings and address the known security vulnerabilities.
41
36
42
37
### Security vulnerabilities found with updates
43
38
@@ -79,30 +74,16 @@ On NuGet.org, you can navigate to the package details page and click `Report pac
79
74
If no security vulnerabilities are found, this means that packages with known vulnerabilities were not found in your package graph at the present moment of time you checked.
80
75
Since the advisory database can be updated at any time, we recommend regularly checking your `dotnet restore` output and ensuring the same in your continuous integration process.
81
76
82
-
### Setting a security audit mode
83
-
84
-
By default, a security audit is done for top-level dependencies.
85
-
In the case that you'd like to audit both top-level and transitive dependencies, you can set the `<NuGetAuditMode>` MSBuild property to the desired mode in which auditing will run.
86
-
Possible values are `direct` and `all`.
87
-
For example if you wanted to audit all dependencies for security advisories, you can set the following:
88
-
89
-
```xml
90
-
<NuGetAuditMode>all</NuGetAuditMode>
91
-
```
77
+
### Configuring NuGet audit
92
78
93
-
> [!NOTE]
94
-
> Visual Studio 2022 17.8 does not support changing audit mode for SDK style packages.
95
-
> It works from 17.9 Preview 2.
96
-
97
-
### Setting a security audit level
98
-
99
-
In cases where you only care about a certain threshold of a security advisory severity, you can set the `<NuGetAuditLevel>` MSBuild property to the desired level in which auditing will fail.
100
-
Possible values are `low`, `moderate`, `high`, and `critical`.
101
-
For example if you only want to see `moderate`, `high`, and `critical` advisories, you can set the following:
79
+
Audit can be configured via MSBuild properties in a `.csproj` or MSBuild file being evaluated as part of your project.
80
+
We recommend that audit is configured at a repository level.
| NuGetAuditMode | direct |`direct` and `all`| If you'd like to audit both top-level and transitive dependencies, you can set the value to `all`. NuGetAuditMode is not applicable for packages.config projects |
85
+
| NuGetAuditLevel | low |`low`, `moderate`, `high`, and `critical`| If you'd like to see `moderate`, `high`, and `critical` advisories, set the value to `moderate`|
86
+
| NuGetAudit | true |`true` and `false`| If you wish to not receive security audit reports, you can opt-out of the experience entirely by setting the value to `false`|
106
87
107
88
### Excluding advisories
108
89
@@ -123,13 +104,8 @@ You can customize your build to treat these warnings as errors to [treat warning
123
104
For example, if you're already using `<TreatWarningsAsErrors>` to treat all (C#, NuGet, MSBuild, etc) warnings as errors, you can use `<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>` to prevent vulnerabilities discovered in the future from breaking your build.
124
105
Alternatively, if you want to keep low and moderate vulnerabilities as warnings, but treat high and critical vulnerabilities as errors, and you're not using `TreatWarningsAsErrors`, you can use `<WarningsAsErrors>NU1903;NU1904</WarningsAsErrors>`.
125
106
126
-
### Disabling security auditing
127
-
128
-
At any time you wish to not receive security audit reports, you can opt-out of the experience entirely by setting the following MSBuild property in a `.csproj` or MSBuild file being evaluated as part of your project:
129
-
130
-
```xml
131
-
<NuGetAudit>false</NuGetAudit>
132
-
```
107
+
> [!NOTE]
108
+
> MSBuild properties for message severity such as `NoWarn` and `TreatWarningsAsErrors` are not supported for packages.config projects.
Copy file name to clipboardExpand all lines: docs/concepts/Dependency-Resolution.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,6 +112,21 @@ In some cases, it's not possible to meet all version requirements. As shown belo
112
112
113
113
In these situations, the top-level consumer (the application or package) should add its own direct dependency on Package B so that the [Direct dependency wins](#direct-dependency-wins) rule applies.
114
114
115
+
### Version ranges and prerelease versions with PackageReference
116
+
117
+
It is not unusual for a package to have both stable and prerelease versions available.
118
+
When resolving a dependency graph, NuGet decides whether to consider prerelease versions for a package based on a single rule:
119
+
`If the project or any packages within the graph request a prerelease version of a package, then include both prerelease or stable versions, otherwise consider stable versions only.`
120
+
121
+
In practice, under the lowest applicable rule, this means:
122
+
123
+
| Version Range | Available versions | Selected version |
With `packages.config`, a project's dependencies are written to `packages.config` as a flat list. Any dependencies of those packages are also written in the same list. When packages are installed, NuGet might also modify the `.csproj` file, `app.config`, `web.config`, and other individual files.
@@ -122,6 +137,11 @@ By default, NuGet 2.8 looks for the lowest patch version (see [NuGet 2.8 release
122
137
123
138
The `packages.config` process for resolving dependencies gets complicated for larger dependency graphs. Each new package installation requires a traversal of the whole graph and raises the chance for version conflicts. When a conflict occurs, installation is stopped, leaving the project in an indeterminate state, especially with potential modifications to the project file itself. This is not an issue when using other package management formats.
124
139
140
+
### Version ranges and prerelease versions with packages.config
141
+
142
+
packages.config resolution does not allow mixing of stable and pre-release dependency in a graph.
143
+
If a dependency is expressed with a range like `[1.0.0, 2.0.0)`, pre-release packages are not allowed in the graph.
144
+
125
145
## Managing dependency assets
126
146
127
147
When using the PackageReference format, you can control which assets from dependencies flow into the top-level project. For details, see [PackageReference](../consume-packages/package-references-in-project-files.md#controlling-dependency-assets).
Copy file name to clipboardExpand all lines: docs/concepts/Package-Versioning.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,8 @@ Note that versions such as `1.0.1-rc.10` and `1.0.1-rc.2` are not parsable by ol
95
95
If you use numerical suffixes with pre-release tags that might use double-digit numbers (or more), use leading zeroes as in beta01 and beta05 to ensure that they sort correctly when the numbers get larger.
96
96
This recommendation only applies this schema.
97
97
98
+
Despite the ordering shown above, NuGet does not always consider both stable & prerelease packages during dependency resolution. Those rules are detailed in [Dependency Resolution](./Dependency-Resolution.md).
Copy file name to clipboardExpand all lines: docs/consume-packages/configuring-nuget-behavior.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,14 +114,15 @@ Multiple `NuGet.Config` files allow you to store settings in different locations
114
114
These settings collectively apply to any NuGet operation invoked from the command line or from Visual Studio, with settings that exist "closest" to a solution or the current folder taking precedence.
115
115
If a command line tool is used on a project file, rather than a solution file, then the project directory is used as the "solution directory", which can lead to inconsistent behaviour when there is a `NuGet.Config` file in a subdirectory of the solution file.
116
116
117
-
Specifically, NuGet loads settings from the different config files in the following order:
117
+
Specifically, when a config file is not specified explicitly on the command line, NuGet loads settings from the different config files in the following order:
118
118
119
119
1. The [`NuGetDefaults.Config` file](#nuget-defaults-file), which contains settings related only to package sources.
120
120
1. The computer-level file.
121
121
1. The user-level file.
122
-
1. The file specified with `-configFile`.
123
122
1. Files found in every folder in the path from the drive root to the current folder (where `nuget.exe` is invoked or the folder containing the Visual Studio solution). For example, if a command is invoked in `c:\A\B\C`, NuGet looks for and loads config files in `c:\`, then `c:\A`, then `c:\A\B`, and finally `c:\A\B\C`.
124
123
124
+
When a config file is explicitly specified on the command line, for example `nuget -configFile my.config` or `dotnet restore --configfile my.config`, only the settings from the specified file will be used.
125
+
125
126
As NuGet finds settings in these files, they are applied as follows:
126
127
127
128
1. For single-item elements, NuGet replaced any previously-found value for the same key. This means that settings that are "closest" to the current folder or solution override any others found earlier. For example, the `defaultPushSource` setting in `NuGetDefaults.Config` is overridden if it exists in any other config file.
0 commit comments