Skip to content

Add nuget.org as NuGet audit source for PR builds - #6987

Merged
marcpopMSFT merged 12 commits into
mainfrom
marcpopMSFT-audit-source-for-prs
Jun 9, 2026
Merged

marcpopMSFT merged 12 commits into
mainfrom
marcpopMSFT-audit-source-for-prs

Conversation

@marcpopMSFT

Copy link
Copy Markdown
Member

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 RestoreAuditSources pointing to https://api.nuget.org/v3/index.json for non-official builds so that NuGet audit can fetch advisories during PR validation.

Testing

The second commit intentionally downgrades System.Security.Cryptography.Xml to 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

  1. Directory.Build.props: Add RestoreAuditSources property targeting nuget.org, conditioned on non-official builds
  2. eng/Versions.props: Temporary downgrade of System.Security.Cryptography.Xml for validation

Copilot AI review requested due to automatic review settings June 3, 2026 00:11
@marcpopMSFT
marcpopMSFT requested review from a team as code owners June 3, 2026 00:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 RestoreAuditSources for non-official builds to use https://api.nuget.org/v3/index.json.
  • Temporarily downgrade System.Security.Cryptography.Xml to 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.

Comment thread Directory.Build.props Resolved
Comment thread Directory.Build.props Resolved
Comment thread eng/Versions.props Resolved
@marcpopMSFT
marcpopMSFT force-pushed the marcpopMSFT-audit-source-for-prs branch 2 times, most recently from 9a778c9 to de9e16c Compare June 3, 2026 00:41
marcpopMSFT and others added 2 commits June 2, 2026 17:58
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]>
@marcpopMSFT
marcpopMSFT force-pushed the marcpopMSFT-audit-source-for-prs branch from de9e16c to 61a664a Compare June 3, 2026 00:58
Comment thread Directory.Build.props Resolved

@ViktorHofer ViktorHofer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@marcpopMSFT

Copy link
Copy Markdown
Member Author

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).

@ViktorHofer

Copy link
Copy Markdown
Member

<EnvironmentVariables Include="NuGetAudit=false" />
-> NuGet Audit is disabled when building source-only (not sure why). The SB offline errors are from the VMR orchestrator - so the outer repo - dotnet/dotnet itself. I think you want to disable it in a file that is imported by both the repo infra and Arcade SDK infra. eng/Versions.props should work.

marcpopMSFT and others added 6 commits June 5, 2026 08:35
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]>
@marcpopMSFT
marcpopMSFT requested a review from ViktorHofer June 8, 2026 18:31
@marcpopMSFT

Copy link
Copy Markdown
Member Author

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 ViktorHofer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good progress. This only enables NuGet Audit in the VMR orchestrator - the non-interesting part of the VMR. Is that intentional?

@marcpopMSFT

Copy link
Copy Markdown
Member Author

@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.

@marcpopMSFT
marcpopMSFT merged commit 208ef23 into main Jun 9, 2026
11 checks passed
@marcpopMSFT
marcpopMSFT deleted the marcpopMSFT-audit-source-for-prs branch June 9, 2026 16:59
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.

4 participants