Skip to content

Commit 416e7e0

Browse files
authored
Dev/saars/upgrade packages to avoid vulnerable (#376)
* Enable central package * Bump up nuget package versions * Get rid of a unnecessary package reference * Down version of the extension packages to 8.x series * Bookkeeping unit tests
1 parent 3d2bd08 commit 416e7e0

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

src/ApplicationInsights.Kubernetes.HostingStartup/ApplicationInsights.Kubernetes.HostingStartup.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<!-- Explicit reference Microsoft.AspNetCore.Hosting even though it would be brought in by dependencies. -->
16-
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
17-
18-
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
15+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
1916
</ItemGroup>
2017

2118
<ItemGroup>

src/ApplicationInsights.Kubernetes/ApplicationInsights.Kubernetes.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Features>IOperation</Features>
44
</PropertyGroup>
@@ -18,15 +18,15 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="KubernetesClient" Version="12.1.1" />
22-
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
23-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
24-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
25-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
26-
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="3.1.27" />
27-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
28-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4" />
29-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.2" />
21+
<PackageReference Include="KubernetesClient" />
22+
<PackageReference Include="Microsoft.ApplicationInsights" />
23+
<PackageReference Include="Microsoft.Extensions.Configuration" />
24+
<PackageReference Include="Microsoft.Extensions.Hosting" />
25+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
26+
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" />
27+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
28+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
29+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

src/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project>
1+
<Project>
22
<!-- <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> -->
33
<!--Build-->
44
<PropertyGroup>
@@ -32,7 +32,7 @@
3232
<RepositoryType />
3333
</PropertyGroup>
3434
<ItemGroup Condition=" '$(IsCIBuild)' == 'true' ">
35-
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
35+
<PackageReference Include="MicroBuild.Core">
3636
<PrivateAssets>all</PrivateAssets>
3737
</PackageReference>
3838
</ItemGroup>

src/Directory.Packages.props

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageVersion Include="KubernetesClient" Version="12.1.1" />
8+
<PackageVersion Include="MicroBuild.Core" Version="0.3.0" />
9+
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
10+
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.22.0" />
11+
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
12+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
13+
<PackageVersion Include="Microsoft.Extensions.DiagnosticAdapter" Version="3.1.32" />
14+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
15+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
16+
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
17+
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
18+
</ItemGroup>
19+
</Project>

tests/UnitTests/PodInfoManagerTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task GetMyPodAsyncShouldGetCorrectPod()
3131
containerIdHolderMock.Setup(c => c.ContainerId).Returns("containerId");
3232

3333
PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object });
34-
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
34+
V1Pod result = await target.GetMyPodAsync(default);
3535

3636
Assert.NotNull(result);
3737
Assert.Single(result.Status.ContainerStatuses);
@@ -58,7 +58,7 @@ public async Task GetMyPodAsyncShouldLeveragePodNameProviders()
5858
k8sQueryClientMock.Setup(c => c.GetPodByNameAsync(It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(podsArray.FirstOrDefault(item => item.Metadata.Name == providerPodName)));
5959

6060
PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object });
61-
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
61+
V1Pod result = await target.GetMyPodAsync(default);
6262

6363
Assert.NotNull(result);
6464
Assert.Single(result.Status.ContainerStatuses);
@@ -88,7 +88,7 @@ public async Task GetMyPodAsyncShouldFallbackToUseContainerIdWhenProvidedPodName
8888
containerIdHolderMock.Setup(c => c.ContainerId).Returns(targetContainerId);
8989

9090
PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object });
91-
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
91+
V1Pod result = await target.GetMyPodAsync(default);
9292

9393
Assert.NotNull(result);
9494
Assert.Single(result.Status.ContainerStatuses);
@@ -119,7 +119,7 @@ public async Task GetMyPodAsyncShouldSupportMultipleIPodNameProviders()
119119
podNameProviderMock2.Setup(p => p.TryGetPodName(out providerPodName2)).Returns(true); // the provider returns true with pod name.
120120

121121
PodInfoManager target = new PodInfoManager(k8sQueryClientMock.Object, containerIdHolderMock.Object, new IPodNameProvider[] { podNameProviderMock.Object, podNameProviderMock2.Object });
122-
V1Pod result = await target.GetMyPodAsync(default).ConfigureAwait(false);
122+
V1Pod result = await target.GetMyPodAsync(default);
123123

124124
Assert.NotNull(result);
125125
Assert.Single(result.Status.ContainerStatuses);

tests/UnitTests/UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
1515
<PackageReference Include="Moq" Version="4.*" />
1616
<PackageReference Include="xunit" Version="2.8.*" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.*" />

0 commit comments

Comments
 (0)