Mark Microsoft.SourceLink.GitHub PrivateAssets=all so it is not a consumer dependency in the nuspec - #1868
Conversation
… the nuspec SourceLink is a build-time-only package, but without PrivateAssets the umbrella NPOI.Pack project writes Microsoft.SourceLink.GitHub into the nuspec as a real consumer dependency in every TFM group. That pulls Microsoft.Build.Tasks.Git into every consumer's restore graph, where GHSA-23fw-v26w-5fgq (CVE-2026-62900) on 8.0.0 now fails restore under NuGet audit (NU1902) even though none of its assets are ever used. Upstream already bumped the package to 10.0.401, which clears the advisory; PrivateAssets=all removes the node from the nuspec entirely so the next advisory on this package cannot break consumers again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 9717aa4)
|
The
The other five assembly/TFM combinations in this run all passed (net472: 2804 / 1866 / 79; net10.0: 2801 / 79), and (Comment by Claude, an AI assistant, on Ken's behalf.) |
|
LGTM |
NPOI 2.8.0on nuget.org declaresMicrosoft.SourceLink.GitHub 8.0.0as a dependency in all five TFM groups of its nuspec. SourceLink is a build-time-only package (it andMicrosoft.Build.Tasks.Gitboth mark themselvesdevelopmentDependency=true), and NPOI even declares the edge withexclude="Build,Analyzers", so consumers never import anything from it. Butdotnet restoreaudits the whole resolved graph regardless of asset exclusion. So on 2026-09-08, when GHSA-23fw-v26w-5fgq (CVE-2026-62900) was published againstMicrosoft.Build.Tasks.Git 8.0.0, every NPOI consumer that promotes NuGet audit warnings to errors went red on NU1902 through a node it never asked for and cannot use. #1866 moved this repo to 10.0.401, which clears today's advisory for the next release; this PR removes the root cause so the next advisory on that package line cannot reach consumers at all.The leak comes from the umbrella
solution/NPOI.Pack.csproj: itsProjectReferences arePrivateAssets="all", so the library projects contribute nothing to the nuspec, and everyPackageReferencein the Pack project itself becomes a consumer dependency unless it carriesPrivateAssets="all". This PR adds that to the SourceLink reference there, and to the same reference in the four library projects for consistency, so a future change to how the package is assembled cannot reintroduce it.Before / after, comparing the published 2.8.0 nuspec with
dotnet pack solution/NPOI.Pack.csproj -c Releaseon this branch:Microsoft.SourceLink.GitHub 8.0.0presentEvery other dependency in every group is unchanged. SourceLink itself keeps working exactly as before: the package is still restored and its build assets still apply to each project; only the nuspec dependency entry disappears.
The same change has been in the swyfft-insurance fork since 2026-09-09 (swyfft-insurance#5), where the rebuilt package was verified against a consumer solution of about 180 projects: neither SourceLink package nor
Microsoft.Build.Tasks.Gitappears anywhere in the resolved graph any more.(PR opened by Claude, an AI assistant, on Ken's behalf.)