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

Component governance updates #3484

Merged
merged 4 commits into from
Sep 7, 2023
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
30 changes: 22 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
<Project>
<!-- Shared dependencies versions.-->
<PropertyGroup>
<HealthcareSharedPackageVersion>6.2.140</HealthcareSharedPackageVersion>
<HealthcareSharedPackageVersion>6.2.149</HealthcareSharedPackageVersion>
<Hl7FhirVersion>4.3.0</Hl7FhirVersion>
</PropertyGroup>

<ItemGroup Label="CVE Mitigation">
<!--Please include the CGA id if possible-->

<PackageVersion Include="System.Security.Cryptography.Xml" Version="7.0.1" />

<!--CVE-2023-29331-->
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="7.0.3" />

<!-- CVE-2021-26701 -->
<PackageVersion Include="System.Text.Encodings.Web" Version="7.0.0" />

<!-- CVE-2020-1045 -->
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />

<!-- CVE-2022-26907 -->
<PackageVersion Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
</ItemGroup>

<!-- SDK Packages -->
<Choose>
<When Condition="'$(TargetFramework)' == 'net7.0'">
Expand Down Expand Up @@ -49,16 +68,13 @@
<PackageVersion Include="MediatR" Version="12.1.1" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNetPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageVersion Include="Microsoft.AspNetCore.JsonPatch" Version="$(AspNetPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(AspNetPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="$(AspNetPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(AspNetPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(AspNetPackageVersion)" />
<PackageVersion Include="Microsoft.Azure.ContainerRegistry" Version="1.0.0-preview.2" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.35.3" />
<PackageVersion Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageVersion Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageVersion Include="Microsoft.Azure.Storage.Blob" Version="11.2.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="$(RuntimePackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
Expand Down Expand Up @@ -87,6 +103,7 @@
<PackageVersion Include="Microsoft.Health.SqlServer" Version="$(HealthcareSharedPackageVersion)" />
<PackageVersion Include="Microsoft.Health.Test.Utilities" Version="$(HealthcareSharedPackageVersion)" />
<PackageVersion Include="Microsoft.Health.Tools.Sql.Tasks" Version="$(HealthcareSharedPackageVersion)" />
<PackageVersion Include="Microsoft.Identity.Web" Version="2.13.3" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
Expand All @@ -110,9 +127,6 @@
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Private.ServiceModel" Version="4.10.2" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="7.0.1" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="7.0.3" />
<PackageVersion Include="System.Text.Encodings.Web" Version="7.0.0" />
<PackageVersion Include="xunit.extensibility.core" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
Expand All @@ -121,4 +135,4 @@
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
<PackageVersion Include="Moq" Version="4.18.1" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,46 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using EnsureThat;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Extensions.Logging;
using Microsoft.Health.Fhir.Core.Features.Operations;

namespace Microsoft.Health.Fhir.Azure.ExportDestinationClient
{
public class AzureAccessTokenProvider : IAccessTokenProvider
{
private readonly AzureServiceTokenProvider _azureServiceTokenProvider;
private readonly DefaultAzureCredential _azureServiceTokenProvider;
private readonly ILogger<AzureAccessTokenProvider> _logger;

public AzureAccessTokenProvider(ILogger<AzureAccessTokenProvider> logger)
{
EnsureArg.IsNotNull(logger, nameof(logger));

_azureServiceTokenProvider = new AzureServiceTokenProvider();
_azureServiceTokenProvider = new DefaultAzureCredential();
_logger = logger;
}

public async Task<string> GetAccessTokenForResourceAsync(Uri resourceUri, CancellationToken cancellationToken)
{
EnsureArg.IsNotNull(resourceUri, nameof(resourceUri));

string accessToken;
// https://learn.microsoft.com/en-us/dotnet/api/overview/azure/app-auth-migration?view=azure-dotnet
var accessTokenContext = new TokenRequestContext(scopes: new[] { resourceUri + "/.default" });

AccessToken accessToken;
try
{
accessToken = await _azureServiceTokenProvider.GetAccessTokenAsync(resourceUri.ToString(), cancellationToken: cancellationToken);
accessToken = await _azureServiceTokenProvider.GetTokenAsync(accessTokenContext, cancellationToken: cancellationToken);
}
catch (AzureServiceTokenProviderException ex)
catch (CredentialUnavailableException ex)
{
_logger.LogWarning(ex, "Failed to retrieve access token");
throw new AccessTokenProviderException(Resources.CannotGetAccessToken);
}

if (accessToken == null)
if (string.IsNullOrEmpty(accessToken.Token))
{
_logger.LogWarning("Failed to retrieve access token");

Expand All @@ -52,7 +56,7 @@ public async Task<string> GetAccessTokenForResourceAsync(Uri resourceUri, Cancel
_logger.LogInformation("Successfully retrieved access token");
}

return accessToken;
return accessToken.Token;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<NeutralLanguage></NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Storage.Blobs" />
<PackageReference Include="Ensure.That" />
<PackageReference Include="Microsoft.Azure.KeyVault" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" />
<PackageReference Include="Polly" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<PackageReference Include="Microsoft.Health.Abstractions" />
<PackageReference Include="Microsoft.Health.Core" />
<PackageReference Include="Microsoft.Health.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" />
<PackageReference Include="Hl7.Fhir.Support.Poco" />
<PackageReference Include="Hl7.Fhir.Serialization" />
<PackageReference Include="Hl7.FhirPath" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -87,7 +88,7 @@
<Message Importance="High" Text="EmbeddedResource files: @(EmbeddedResource)" />
</Target>
-->

<Target Name="ComputeGeneratorInputs" BeforeTargets="GenerateFiles">
<ItemGroup>
<MutableSqlGeneratorInputs Include="@(EmbeddedResource)" Condition="'%(EmbeddedResource.InputToMutableSqlGenerator)' == 'true'" />
Expand Down