Skip to content

Suppress NU1902/NU1903 so a new advisory doesn't break clean builds - #6

Open
johnnyxmas wants to merge 2 commits into
janholtzhausen:mainfrom
johnnyxmas:fix/nuget-audit-warnings-not-fatal
Open

johnnyxmas wants to merge 2 commits into
janholtzhausen:mainfrom
johnnyxmas:fix/nuget-audit-warnings-not-fatal

Conversation

@johnnyxmas

Copy link
Copy Markdown

Summary

TreatWarningsAsErrors is enabled project-wide in src/Directory.Build.props, which makes NuGet's restore-time security-advisory audit fatal for any dependency with a published advisory. As of this writing that's MailKit 4.15.1 (GHSA-9j88-vvj5-vhgr) and Microsoft.OpenApi 2.4.1 (GHSA-v5pm-xwqc-g5wc), but the underlying issue isn't those two packages specifically -- it's that a clean dotnet restore with no NuGet package cache breaks entirely the moment any advisory is published for anything in the dependency graph, independent of anything in this repo's own code.

I ran into this doing a from-scratch Docker build (docker build . with no local NuGet cache to mask it), which is presumably why it hasn't come up before -- a machine with these packages already restored from before the advisories existed won't re-trigger the audit on incremental builds.

Change

Suppressed via the existing NoWarn convention (same pattern already used for CS1591/CA1416 two lines up) rather than disabling the audit outright, so advisories stay visible in build output for awareness -- they just don't hard-fail the build.

Test plan

  • Reproduced the failure with a clean docker build . (no cache): error NU1902 for MailKit, error NU1903 for Microsoft.OpenApi, restore fails for Readarr.Core, Readarr.Http, NzbDrone.Host, etc.
  • Confirmed the same clean build succeeds with this change applied

TreatWarningsAsErrors is enabled project-wide, which makes NuGet's
restore-time security-advisory audit fatal for any dependency with a
published advisory. As of this commit that's MailKit 4.15.1
(GHSA-9j88-vvj5-vhgr) and Microsoft.OpenApi 2.4.1
(GHSA-v5pm-xwqc-g5wc), but the underlying issue isn't those two
packages specifically -- it's that a clean `dotnet restore` with no
NuGet package cache breaks entirely the moment any advisory is
published for anything in the dependency graph, independent of
anything in this repo's own code.

Ran into this doing a from-scratch Docker build (no local NuGet cache
to mask it), which is presumably why it hadn't surfaced before.

Suppressed via the existing NoWarn convention rather than disabling the
audit outright, so advisories stay visible in build output.
The explanatory comment in the previous commit contained a literal '--'
sequence, which XML disallows inside comments. That made
src/Directory.Build.props unparseable, so ManagePackageVersionsCentrally
was never applied and every PackageReference fell back to its lowest
available version, failing restore with NU1015 and spurious NU1107
version conflicts.
@johnnyxmas

Copy link
Copy Markdown
Author

Correction: the first push of this branch had a bug of my own making. The explanatory comment I added alongside the suppression contained a literal --, which XML does not permit inside a comment. That made src/Directory.Build.props unparseable, so ManagePackageVersionsCentrally was never applied, every PackageReference fell back to its lowest available version, and restore failed with NU1015 plus a pile of spurious NU1107 version conflicts.

Fixed in 1870d07 (reworded to avoid the --). The functional change is unchanged and is still just the two added NoWarn codes. Apologies for the noise.

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.

1 participant