Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Component Governance alerts #254

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PropertyGroup>
<WarningsAsErrors />
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Warning 1701;1702: These two compiler warnings are raised when a reference is bound to a different version
<!-- Warning 1701;1702: These two compiler warnings are raised when a reference is bound to a different version
than specified in the assembly reference version number. -->
<!-- Warning NU1701: Warning for using Nuget packages in a .Net Core project compiled in .Net Framework. -->
<NoWarn>1701;1702;NU1701</NoWarn>
Expand Down Expand Up @@ -42,13 +42,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.22.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.12" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.12" />
<PackageReference Include="Microsoft.FeatureManagement" Version="2.2.0" />
<PackageReference Include="Azure.Identity" Version="1.11.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.FeatureManagement" Version="2.2.0" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
</ItemGroup>

<!-- Component Governance fix Item Group. -->
Expand All @@ -57,6 +56,7 @@
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.WindowsPackageManager.Rest\Microsoft.WindowsPackageManager.Rest.csproj" />
Expand Down
8 changes: 1 addition & 7 deletions src/WinGet.RestSource.Functions/SourceFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="SourceFunctions.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand Down Expand Up @@ -311,8 +311,6 @@ internal async Task<SourceResultOutputHelper> SourceOrchestratorHelperAsync<TFun
customDimensions.Add("FunctionName", executionContext.FunctionName);
customDimensions.Add("OperationId", inputHelper.OperationId);

this.telemetryClient.TrackEvent("ExecutionStart", customDimensions);

durableContext.LogInfo($"{loggingContext}{orchestrationFunction} executed at: {durableContext.CurrentUtcDateTime}." +
$" Calling {activityFunction} activity function.");

Expand All @@ -326,10 +324,7 @@ internal async Task<SourceResultOutputHelper> SourceOrchestratorHelperAsync<TFun
catch (Exception e)
{
durableContext.LogError($"{loggingContext}Error occurred in SourceOrchestratorHelperAsync {e}");

this.telemetryClient.TrackException(e, customDimensions);
customDimensions.Add("Exception", e.GetType().FullName);

Metrics.EmitMetric(errorMetric, customDimensions, logger);
}
finally
Expand All @@ -339,7 +334,6 @@ internal async Task<SourceResultOutputHelper> SourceOrchestratorHelperAsync<TFun
durableContext.LogInfo($"{loggingContext}Task result: {sourceResultOutput}");
}

this.telemetryClient.TrackEvent("ExecutionCompleted", customDimensions);
customDimensions.Add("Result", sourceResultOutput.ToString());
}

Expand Down
7 changes: 5 additions & 2 deletions src/WinGet.RestSource.Functions/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Microsoft.WinGet.RestSource.Functions
using Microsoft.WinGet.RestSource.Interfaces;
using Microsoft.WinGet.RestSource.Utils.Common;
using Microsoft.WinGet.RestSource.Utils.Constants;
using YamlDotNet.Core.Tokens;

/// <summary>
/// Azure function startup class.
Expand Down Expand Up @@ -66,12 +67,14 @@ private static void InjectTelemetryConfiguration(IFunctionsHostBuilder builder)
builder.Services.AddSingleton<TelemetryConfiguration>(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;
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PropertyGroup>
<WarningsAsErrors />
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Warning 1701;1702: These two compiler warnings are raised when a reference is bound to a different version
<!-- Warning 1701;1702: These two compiler warnings are raised when a reference is bound to a different version
than specified in the assembly reference version number. -->
<!-- Warning NU1701: Warning for using Nuget packages in a .Net Core project compiled in .Net Framework. -->
<NoWarn>1701;1702;NU1701</NoWarn>
Expand Down Expand Up @@ -46,7 +46,7 @@
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.7.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.7.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.13.5" />
</ItemGroup>

<!-- Component Governance fix Item Group. -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="SourceFunctionsTests.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion src/WinGet.RestSource/WinGet.RestSource.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.22.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Azure.Identity" Version="1.11.3" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
</ItemGroup>

<!-- Component Governance fix Item Group. -->
Expand All @@ -56,6 +56,7 @@
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
</ItemGroup>

<ItemGroup>
Expand Down