Repository navigation
Add nuget.org as NuGet audit source for PR builds - #6987
Conversation
There was a problem hiding this comment.
Pull request overview
Adds configuration intended to re-enable NuGet vulnerability auditing for PR builds by explicitly pointing audit advisory lookups at nuget.org (while keeping audit disabled for official builds due to the MSBuild warning-handling issue).
Changes:
- Add
RestoreAuditSourcesfor non-official builds to usehttps://api.nuget.org/v3/index.json. - Temporarily downgrade
System.Security.Cryptography.Xmlto trigger known-audit warnings during PR validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Directory.Build.props | Adds nuget.org as an audit source for non-official builds and adjusts audit-related warning behavior. |
| eng/Versions.props | Temporarily downgrades System.Security.Cryptography.Xml for audit validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9a778c9 to
de9e16c
Compare
The Azure DevOps feeds in NuGet.config don't serve vulnerability advisory data. Add NuGetAuditSources pointing to nuget.org so NuGet audit can fetch advisories during non-official (PR) builds. Official builds continue to have audit disabled due to the MSBuild WarningsNotAsErrors issue (dotnet/msbuild#10801). Co-authored-by: Copilot <[email protected]>
Temporarily set to 10.0.6 (below the 10.0.8 CVE fix) to verify NuGet audit flags it during PR builds. Version 10.0.6 is used instead of lower versions to avoid NU1109 package downgrade errors in CPM (transitive deps require >= 10.0.6). This commit should be reverted before merge. Co-authored-by: Copilot <[email protected]>
de9e16c to
61a664a
Compare
ViktorHofer
left a comment
There was a problem hiding this comment.
For others, we have an offline chat about this. NuGetAuditSources isn't a property that NuGet reads so this doesn't work. We recommended to use data.nuget.org in NuGet.config and switching the NuGetAudit property to false for official builds.
|
Looks like it works as expected but the offline build can't access the audit source and fails. I think we need to suppress that warning in that build or disable audit in that build (assuming disabling audit is enough to take care of that warning message). |
|
dotnet/repo-projects/Directory.Build.props Line 225 in 0068a02 |
NuGet still attempts to contact auditSources configured in NuGet.config even when NuGetAudit=false, generating NU1905 warnings that get promoted to errors via TreatWarningsAsErrors. Suppress NU1905 for offline builds at both the VMR orchestrator level and for inner repo builds. Co-authored-by: Copilot <[email protected]>
The arcade toolset projects have their own Directory.Build.props which prevents MSBuild from traversing up to the VMR root where NuGetAudit is conditionally disabled. Setting NuGetAudit=false as an environment variable ensures it applies to all MSBuild invocations including the arcade bootstrap restore. sudo -E preserves the env var through the network namespace isolation. Co-authored-by: Copilot <[email protected]>
Move NuGetAudit=false from pipeline YAML to eng/Versions.props, which is imported by all projects including arcade toolset bootstrap projects (Tools.proj, Publish.proj) that don't see the VMR root Directory.Build.props. Uses the same DotNetBuildWithOnlineFeeds condition as the root props file. Co-authored-by: Copilot <[email protected]>
…ficient Remove NoWarn=NU1905 from Directory.Build.props and the NoWarn env var from repo-projects/Directory.Build.props. The NuGetAudit=false setting in eng/Versions.props should be sufficient to prevent NU1905 entirely. Co-authored-by: Copilot <[email protected]>
….Xml to 10.0.8 Upgrade Microsoft.Build from 17.12.50 to 18.0.2 to resolve audit vulnerability findings. Pin System.Security.Cryptography.Xml to 10.0.8 in both eng/Versions.props and Directory.Packages.props to address its known vulnerability. Co-authored-by: Copilot <[email protected]>
|
I've confirmed that this is the minimum set of changes needed to have audit flag in PR builds, not fail in offline builds because of access to nuget.org, and not fail in CI. I ran both PR and CI with commit 24d1b19 and the PR build only failed with expected audit errors and CI didn't fail. |
ViktorHofer
left a comment
There was a problem hiding this comment.
Good progress. This only enables NuGet Audit in the VMR orchestrator - the non-interesting part of the VMR. Is that intentional?
|
@ViktorHofer The orchestrator was the one being flagged before so that's what I targeted. I think I should merge this and then do any follow-ups as a separate PR. Are there additional places you think I should target that would be the most valuable? I wasn't planning on doing every nuget.config in the repo. |
Summary
Follow-up to #6753. The prior change disabled NuGet audit for official builds to work around dotnet/msbuild#10801, but it also effectively disabled audit for PR validation because the Azure DevOps feeds in NuGet.config don't serve vulnerability advisory data.
This PR adds
RestoreAuditSourcespointing tohttps://api.nuget.org/v3/index.jsonfor non-official builds so that NuGet audit can fetch advisories during PR validation.Testing
The second commit intentionally downgrades
System.Security.Cryptography.Xmlto 10.0.0 (which has known vulnerabilities) to verify the audit source works. If the PR build flags NU1903/NU1904 warnings, the configuration is working correctly. That commit should be reverted before merge.Changes
RestoreAuditSourcesproperty targeting nuget.org, conditioned on non-official builds