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

Merges dev into master #1321

Merged
merged 5 commits into from
Jan 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.13.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.14.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.4.5" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.5.0" />
<PackageReference Include="System.Text.Json" Version="7.0.1" />
</ItemGroup>

Expand Down
12 changes: 5 additions & 7 deletions FileService/Services/AzureBlobStorageUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class AzureBlobStorageUtility : IFileUtility
{
private readonly IConfiguration _configuration;
private readonly string _connectionString;
private string _containerName;
private string _blobName;

public AzureBlobStorageUtility(IConfiguration configuration)
{
Expand All @@ -40,29 +38,29 @@ public async Task<string> ReadFromFile(string filePathSource)
FileServiceHelper.CheckArgumentNullOrEmpty(filePathSource, nameof(filePathSource));
CheckFileFormat(filePathSource);

(_containerName, _blobName) = FileServiceHelper.RetrieveFilePathSourceValues(filePathSource);
(var containerName, var blobName) = FileServiceHelper.RetrieveFilePathSourceValues(filePathSource);

if (CloudStorageAccount.TryParse(_connectionString, out CloudStorageAccount storageAccount))
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(_containerName);
CloudBlobContainer container = blobClient.GetContainerReference(containerName);

if (await container.ExistsAsync())
{
CloudBlockBlob blob = container.GetBlockBlobReference(_blobName);
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);

if (await blob.ExistsAsync())
{
return await blob.DownloadTextAsync();
}
else
{
throw new IOException($"The '{_blobName}' blob doesn't exist.");
throw new IOException($"The '{blobName}' blob doesn't exist.");
}
}
else
{
throw new IOException($"The '{_containerName}' container doesn't exist.");
throw new IOException($"The '{containerName}' container doesn't exist.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion OpenAPIService.Test/OpenAPIService.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.OpenApi" Version="1.4.5" />
<PackageReference Include="Microsoft.OpenApi" Version="1.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
6 changes: 3 additions & 3 deletions OpenAPIService/OpenAPIService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.2" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.13.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.4.5" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.14.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.5.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.2.0-preview9" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.4.5" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
35 changes: 3 additions & 32 deletions PermissionsService/Services/PermissionsStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ is to be seeded by only one executing thread.

// Get file contents from source
string scopesInfoJson = _fileUtility.ReadFromFile(relativeScopesInfoPath).GetAwaiter().GetResult();
_telemetryClient?.TrackTrace($"Successfully seeded permissions for locale '{locale}' from Azure blob resource, file length: {scopesInfoJson.Length}",
_telemetryClient?.TrackTrace($"Successfully seeded permissions for locale '{locale}' from Azure blob resource",
SeverityLevel.Information,
_permissionsTraceProperties);

Expand Down Expand Up @@ -302,11 +302,6 @@ private IDictionary<string, IDictionary<string, ScopeInformation>> CreateScopesI
_permissionsTraceProperties);

var scopesInformationList = JsonConvert.DeserializeObject<ScopesInformationList>(scopesInfoJson);

_telemetryClient?.TrackTrace($"DelegatedScopesList count: {scopesInformationList.DelegatedScopesList.Count}, ApplicationScopesList count: {scopesInformationList.ApplicationScopesList.Count}",
SeverityLevel.Information,
_permissionsTracePropertiesWithSanitizeIgnore);

var delegatedScopesInfoTable = scopesInformationList.DelegatedScopesList.ToDictionary(x => x.ScopeName);
var applicationScopesInfoTable = scopesInformationList.ApplicationScopesList.ToDictionary(x => x.ScopeName);

Expand All @@ -316,18 +311,6 @@ private IDictionary<string, IDictionary<string, ScopeInformation>> CreateScopesI
SeverityLevel.Information,
_permissionsTracePropertiesWithSanitizeIgnore);

if (delegatedScopesInfoTable.Count == 0 && applicationScopesInfoTable.Count == 0)
{
// sneak-peak into the scopes JSON if we didn't get any scopes
const int maxCharsToLog = 100;
var scopesInfoJsonToLog = scopesInfoJson[0..int.Max(maxCharsToLog, scopesInfoJson.Length)]
.Replace("\r", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace("\n", string.Empty, StringComparison.OrdinalIgnoreCase);
_telemetryClient?.TrackTrace($"Scopes information is empty. ScopesInfoJson start: {scopesInfoJsonToLog}",
SeverityLevel.Error,
_permissionsTracePropertiesWithSanitizeIgnore);
}

return new Dictionary<string, IDictionary<string, ScopeInformation>>
{
{ Delegated, delegatedScopesInfoTable },
Expand Down Expand Up @@ -510,24 +493,12 @@ private List<ScopeInformation> GetScopesInformation(IDictionary<string, IDiction
_permissionsTraceProperties);
}

var scopeInfoMissing = false;
var scopesInfo = scopes.Select(scope =>
{
if (scopesInformationDictionary[key].TryGetValue(scope, out var scopeInfo))
{
return scopeInfo;
}
else
{
scopeInfoMissing = true;
return new() { ScopeName = scope };
}
scopesInformationDictionary[key].TryGetValue(scope, out var scopeInfo);
return scopeInfo ?? new() { ScopeName = scope };
}).ToList();

_telemetryClient?.TrackTrace($"scopesInformationDictionary hash code is: {scopesInformationDictionary.GetHashCode()}",
scopeInfoMissing && !getAllPermissions ? SeverityLevel.Error : SeverityLevel.Information,
_permissionsTracePropertiesWithSanitizeIgnore);

if (getAllPermissions)
{
scopesInfo.AddRange(scopesInformationDictionary[key]
Expand Down