Skip to content

Commit 0a39567

Browse files
authored
Enable NuGet audit on all builds (#3713)
1 parent 5395088 commit 0a39567

File tree

6 files changed

+58
-28
lines changed

6 files changed

+58
-28
lines changed

NuGet.config

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
<clear />
55
<add key="sqlclient" value="https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/sqlclient/nuget/v3/index.json" />
66
</packageSources>
7-
<auditSources>
8-
<clear />
9-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
10-
</auditSources>
117
</configuration>

eng/pipelines/common/templates/jobs/build-signed-package-job.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
- template: ../steps/generate-nuget-package-step.yml@self
5252
parameters:
5353
OutputDirectory: $(artifactDirectory)
54+
installNuget: false
5455

5556
- template: ../steps/esrp-code-signing-step.yml@self
5657
parameters:

eng/pipelines/steps/compound-nuget-pack-step.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,26 @@ parameters:
2727
- Project
2828

2929
steps:
30-
- task: NuGetToolInstaller@1
31-
displayName: 'Install Latest Nuget'
32-
inputs:
33-
checkLatest: true
30+
# This tool is failing on OneBranch pipelines, possibly due to new
31+
# network isolation rules:
32+
#
33+
# ERR:Client network socket disconnected before secure TLS connection was established
34+
#
35+
# Our AKV Official build uses this 1ES image:
36+
#
37+
# Image: 1ES-OB-2022-D8-Netlock-V2_westus2_1_image
38+
#
39+
# An ICM for this issue exists:
40+
#
41+
# https://portal.microsofticm.com/imp/v5/incidents/details/690355343/summary
42+
#
43+
# Recommendation is to remove this step since NuGet is already present on
44+
# the 1ES images.
45+
#
46+
# - task: NuGetToolInstaller@1
47+
# displayName: 'Install Latest Nuget'
48+
# inputs:
49+
# checkLatest: true
3450

3551
- ${{ if parameters.generateSymbolsPackage }}:
3652
- task: NuGetCommand@2

src/Directory.Build.props

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,54 @@
6262
<NuGetRoot Condition="'$(NuGetRoot)' == ''">$(RepoRoot).nuget\</NuGetRoot>
6363
<NuGetCmd>$(NuGetRoot)nuget.exe</NuGetCmd>
6464
<!-- Respect environment variable for the .NET install directory if set; otherwise, use the current default location -->
65-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66-
<WarningsNotAsErrors>$(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904;NU1905</WarningsNotAsErrors>
6765
<BuildSimulator Condition="'$(BuildSimulator)' != 'true'">false</BuildSimulator>
6866
</PropertyGroup>
6967
<PropertyGroup Condition="'$(BuildSimulator)' == 'true'">
7068
<DefineConstants>$(DefineConstants);ENCLAVE_SIMULATOR</DefineConstants>
7169
</PropertyGroup>
7270

7371
<!-- NuGet Audit Settings -->
74-
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
72+
<PropertyGroup>
73+
<!--
74+
See the NuGet Audit documentation here:
75+
76+
https://learn.microsoft.com/en-us/nuget/concepts/auditing-packages
77+
-->
78+
7579
<!--
76-
ADO does not support audit/vulnerability feeds, so the audit feed is specified (in
77-
nuget.config) as nuget.org. OneBranch default network isolation does not allow connections
78-
to nuget.org. To avoid this issue, we will disable auditing for official builds, but leave it
79-
enabled for local builds.
80-
@TODO: If/when auditing is enabled for central feeds services, this can be removed.
80+
We always want NuGet auditing enabled. There are no build scenarios
81+
where auditing should be disabled.
8182
-->
82-
<NuGetAudit>false</NuGetAudit>
83+
<NuGetAudit>true</NuGetAudit>
84+
85+
<!-- We want all dependencies audited. -->
86+
<NuGetAuditMode>all</NuGetAuditMode>
87+
88+
<!-- We want all possible audit severity messages. -->
89+
<NuGetAuditLevel>low</NuGetAuditLevel>
8390
</PropertyGroup>
91+
92+
<!-- Build Warning/Error Settings -->
8493
<PropertyGroup>
85-
<NuGetAuditMode>all</NuGetAuditMode>
94+
<!-- We treat all warnings as errors. -->
95+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
96+
97+
<!--
98+
There may be a few specific warnings that should _not_ be considered an
99+
error. This list should be used sparingly to avoid important warnings
100+
being ignored.
101+
-->
102+
<WarningsNotAsErrors></WarningsNotAsErrors>
103+
104+
<!--
105+
If a build is failing due to vulnerable dependencies, you may temporarily
106+
uncomment the following line to treat the audit warnings as non-errors.
107+
This should only be done as a temporary measure while addressing the
108+
vulnerable dependencies. See:
109+
110+
https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1901-nu1904
111+
-->
112+
<!-- <WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors> -->
86113
</PropertyGroup>
87114

88115
<!-- Packaging for source link-->

src/Microsoft.Data.SqlClient/tests/Directory.Build.props

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
<ReferenceType Condition="'$(ReferenceType)'==''">Project</ReferenceType>
1515
</PropertyGroup>
1616

17-
<!-- Audit Settings -->
18-
<PropertyGroup>
19-
<NuGetAudit>false</NuGetAudit>
20-
</PropertyGroup>
21-
2217
<!--These properties can be modified locally to target .NET version of choice to build and test entire test suite-->
2318
<PropertyGroup>
2419
<TargetNetFxVersion Condition="'$(TargetNetFxVersion)' == ''">net462</TargetNetFxVersion>

tools/GenAPI/Directory.Build.props

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,4 @@
44

55
<!-- Import parent Directory.build.props -->
66
<Import Project="..\..\src\Directory.Build.props" />
7-
8-
<!-- Audit Settings -->
9-
<PropertyGroup>
10-
<NuGetAudit>false</NuGetAudit>
11-
</PropertyGroup>
127
</Project>

0 commit comments

Comments
 (0)