From 05d4836affcc6970957bb03b67e26914113438e9 Mon Sep 17 00:00:00 2001 From: Ruben Guerrero Date: Wed, 14 Aug 2024 15:00:20 -0700 Subject: [PATCH] Fix Component Governance alerts (#254) --- .../WinGet.RestSource.AppConfig.csproj | 14 +++++++------- src/WinGet.RestSource.Functions/SourceFunctions.cs | 8 +------- src/WinGet.RestSource.Functions/Startup.cs | 7 +++++-- .../WinGet.RestSource.Functions.csproj | 4 ++-- .../Tests/AzFunctions/SourceFunctionsTests.cs | 4 ++-- src/WinGet.RestSource/WinGet.RestSource.csproj | 3 ++- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/WinGet.RestSource.AppConfig/WinGet.RestSource.AppConfig.csproj b/src/WinGet.RestSource.AppConfig/WinGet.RestSource.AppConfig.csproj index f03cb729..d50639c9 100644 --- a/src/WinGet.RestSource.AppConfig/WinGet.RestSource.AppConfig.csproj +++ b/src/WinGet.RestSource.AppConfig/WinGet.RestSource.AppConfig.csproj @@ -14,7 +14,7 @@ true - 1701;1702;NU1701 @@ -42,13 +42,12 @@ - - - - - - + + + + + @@ -57,6 +56,7 @@ + diff --git a/src/WinGet.RestSource.Functions/SourceFunctions.cs b/src/WinGet.RestSource.Functions/SourceFunctions.cs index 99cb80aa..ae93772e 100644 --- a/src/WinGet.RestSource.Functions/SourceFunctions.cs +++ b/src/WinGet.RestSource.Functions/SourceFunctions.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -311,8 +311,6 @@ internal async Task SourceOrchestratorHelperAsync SourceOrchestratorHelperAsync SourceOrchestratorHelperAsync /// Azure function startup class. @@ -66,12 +67,14 @@ private static void InjectTelemetryConfiguration(IFunctionsHostBuilder builder) builder.Services.AddSingleton(sp => { var key = AzureFunctionEnvironment.AppInsightsInstrumentationKey; + var telemetryConfiguration = new TelemetryConfiguration(); + if (!string.IsNullOrWhiteSpace(key)) { - return new TelemetryConfiguration(key); + telemetryConfiguration.ConnectionString = $"InstrumentationKey={key}"; } - return new TelemetryConfiguration(); + return telemetryConfiguration; }); } } diff --git a/src/WinGet.RestSource.Functions/WinGet.RestSource.Functions.csproj b/src/WinGet.RestSource.Functions/WinGet.RestSource.Functions.csproj index d712dd7a..51f54dbb 100644 --- a/src/WinGet.RestSource.Functions/WinGet.RestSource.Functions.csproj +++ b/src/WinGet.RestSource.Functions/WinGet.RestSource.Functions.csproj @@ -13,7 +13,7 @@ true - 1701;1702;NU1701 @@ -46,7 +46,7 @@ - + diff --git a/src/WinGet.RestSource.UnitTest/Tests/AzFunctions/SourceFunctionsTests.cs b/src/WinGet.RestSource.UnitTest/Tests/AzFunctions/SourceFunctionsTests.cs index d4519e2e..40e15093 100644 --- a/src/WinGet.RestSource.UnitTest/Tests/AzFunctions/SourceFunctionsTests.cs +++ b/src/WinGet.RestSource.UnitTest/Tests/AzFunctions/SourceFunctionsTests.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -51,7 +51,7 @@ public SourceFunctionsTests(ITestOutputHelper log) this.telemetryConfiguration = new TelemetryConfiguration { TelemetryChannel = this.mockTelemetryChannel.Object, - InstrumentationKey = Guid.NewGuid().ToString(), + ConnectionString = $"InstrumentationKey={Guid.NewGuid()}", }; this.mockHttpClientFactory.Setup( diff --git a/src/WinGet.RestSource/WinGet.RestSource.csproj b/src/WinGet.RestSource/WinGet.RestSource.csproj index 9c4cc61c..c4622315 100644 --- a/src/WinGet.RestSource/WinGet.RestSource.csproj +++ b/src/WinGet.RestSource/WinGet.RestSource.csproj @@ -46,7 +46,7 @@ - + @@ -56,6 +56,7 @@ +