Skip to content

Commit

Permalink
Release/1.0.x (#226)
Browse files Browse the repository at this point in the history
* initial set of Terraform script to create a dev VM in Azure

Azure DevOps Server included

* address #185 by removing field when set to null value

* address sonar issues

* Retry after Http 429 using Polly, address #71

* Removed annoying messages about new version check

* Deprecation notice for resourceGroup option

* fix IDataProtectionProvider.CreateProtector purpose string

Improve #192

* New update.mappings command

* final version of update.mappings

Missing: tests & doc

* added integration test for new update.mappings command

* Fix impersonation not triggering
when the rule updates the same work item
that was changed by the user.

* bump GitVersion

* Harden Azure resource (#225)

* Squashed commit of the following:

commit bab34f1b5b93b3d86dca7e2f5c6c25203e33ea15
Merge: c3b4ad1 423f77f
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:21:34 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Hosting-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-host/aggregator-host.csproj

commit c3b4ad131ef295eef73c08103f023fae2c6df8c5
Merge: 1b4407e 88e8bcc
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:21:02 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Azure.WebJobs-3.0.23' into uppers2

    # Conflicts:
    #	src/aggregator-function/aggregator-function.csproj

commit 1b4407eac1eb7bc46d3782285831694868ac3179
Merge: 21523a1 abd25f0
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:20:21 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel-2.16.0' into uppers2

    # Conflicts:
    #	src/aggregator-cli/aggregator-cli.csproj

commit 21523a1e831046a7e8dc6186553f7bcf28e2ab69
Merge: 2ae99ac 86efb3f
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:19:38 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration.EnvironmentVariables-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-function/aggregator-function.csproj
    #	src/aggregator-webshared/aggregator-webshared.csproj

commit 2ae99ac2de92366b051d31f0b25d5b848902dba6
Merge: c53448c 44982ac
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:17:45 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration.Json-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-function/aggregator-function.csproj
    #	src/aggregator-webshared/aggregator-webshared.csproj

commit c53448cf7ee1e97801dfb424480dc8eaeda08ff2
Merge: cf22760 ce43d27
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:16:40 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-shared/aggregator-shared.csproj

commit cf227608b2b49893d25fd3ce468907e0f82b84dc
Merge: ab3ed38 813cd0e
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:16:02 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration.FileExtensions-5.0.0' into uppers2

commit ab3ed3840891cb17e969e5a69e37cf8de9d8b79d
Merge: b3d1656 a668958
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:15:40 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Azure.Management.ResourceManager.Fluent-1.36.0' into uppers2

    # Conflicts:
    #	src/aggregator-cli/aggregator-cli.csproj

commit b3d1656c861e1fb08412cc9e5c405c1d5118bb57
Merge: b324ef9 fc2e7a6
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:14:34 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Azure.Management.Fluent-1.36.0' into uppers2

    # Conflicts:
    #	src/aggregator-cli/aggregator-cli.csproj
    #	src/aggregator-shared/aggregator-shared.csproj

commit b324ef9d783f9811547c85d52d10307293c2db72
Merge: 6c59d10 048b822
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:12:41 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.ApplicationInsights-2.16.0' into uppers2

commit 6c59d10380d1db2ee75327d71da5a46bfea0cf83
Merge: 742a432 8258ac0
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:12:30 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.AspNetCore.DataProtection-5.0.0' into uppers2

commit 742a4320d9a8544d6445eac9af7b1f7f7da9fb19
Merge: 6c5d1a6 5374ab5
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:12:20 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/System.Text.Json-5.0.0' into uppers2

    # Conflicts:
    #	src/unittests-function/unittests-function.csproj

commit 6c5d1a65f94c9967e19d93e94dc8f999a3c9a84b
Merge: 7f38201 4605ea2
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:05:58 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/NSubstitute.Analyzers.CSharp-1.0.14' into uppers

commit 7f38201a9e829e948be3b3b15d88b7f627a8f037
Merge: dca80ab 8bcd3e7
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:05:44 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.NET.Test.Sdk-16.8.0' into uppers

commit dca80abcb3f522313b3b5e0bcea21bea78561193
Merge: e4b94c7 dfa39b0
Author: Giulio Vian <[email protected]>
Date:   Sat Dec 12 16:05:24 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.DependencyInjection-5.0.0' into uppers

commit e4b94c7
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:28:16 2020 +0000

    Bump Microsoft.CodeAnalysis.Scripting from 3.7.0 to 3.8.0 in /src

    Bumps [Microsoft.CodeAnalysis.Scripting](https://github.com/dotnet/roslyn) from 3.7.0 to 3.8.0.
    - [Release notes](https://github.com/dotnet/roslyn/releases)
    - [Changelog](https://github.com/dotnet/roslyn/blob/master/docs/Breaking%20API%20Changes.md)
    - [Commits](https://github.com/dotnet/roslyn/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 5374ab5
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:50 2020 +0000

    Bump System.Text.Json from 4.7.2 to 5.0.0 in /src

    Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 4.7.2 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 8258ac0
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:16 2020 +0000

    Bump Microsoft.AspNetCore.DataProtection from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.AspNetCore.DataProtection](https://github.com/dotnet/aspnetcore) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/aspnetcore/releases)
    - [Commits](dotnet/aspnetcore@v3.1.8...v5.0.0)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 048b822
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:07 2020 +0000

    Bump Microsoft.ApplicationInsights from 2.14.0 to 2.16.0 in /src

    Bumps [Microsoft.ApplicationInsights](https://github.com/Microsoft/ApplicationInsights-dotnet) from 2.14.0 to 2.16.0.
    - [Release notes](https://github.com/Microsoft/ApplicationInsights-dotnet/releases)
    - [Changelog](https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/CHANGELOG.md)
    - [Commits](microsoft/ApplicationInsights-dotnet@2.14.0...2.16.0)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 813cd0e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:05 2020 +0000

    Bump Microsoft.Extensions.Configuration.FileExtensions in /src

    Bumps [Microsoft.Extensions.Configuration.FileExtensions](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit fc2e7a6
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:05 2020 +0000

    Bump Microsoft.Azure.Management.Fluent from 1.34.0 to 1.36.0 in /src

    Bumps [Microsoft.Azure.Management.Fluent](https://github.com/Azure/azure-libraries-for-net) from 1.34.0 to 1.36.0.
    - [Release notes](https://github.com/Azure/azure-libraries-for-net/releases)
    - [Commits](Azure/azure-libraries-for-net@Fluent-v1.34.0...Fluent-v1.36.0)

    Signed-off-by: dependabot[bot] <[email protected]>

commit ce43d27
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.Extensions.Configuration from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.Extensions.Configuration](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit a668958
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.Azure.Management.ResourceManager.Fluent in /src

    Bumps [Microsoft.Azure.Management.ResourceManager.Fluent](https://github.com/Azure/azure-libraries-for-net) from 1.34.0 to 1.36.0.
    - [Release notes](https://github.com/Azure/azure-libraries-for-net/releases)
    - [Commits](Azure/azure-libraries-for-net@Fluent-v1.34.0...Fluent-v1.36.0)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 8bcd3e7
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.0 in /src

    Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.7.1 to 16.8.0.
    - [Release notes](https://github.com/microsoft/vstest/releases)
    - [Commits](microsoft/vstest@v16.7.1...v16.8.0)

    Signed-off-by: dependabot[bot] <[email protected]>

commit dfa39b0
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.Extensions.DependencyInjection in /src

    Bumps [Microsoft.Extensions.DependencyInjection](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 4605ea2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:03 2020 +0000

    Bump NSubstitute.Analyzers.CSharp from 1.0.13 to 1.0.14 in /src

    Bumps [NSubstitute.Analyzers.CSharp](https://github.com/nsubstitute/NSubstitute.Analyzers) from 1.0.13 to 1.0.14.
    - [Release notes](https://github.com/nsubstitute/NSubstitute.Analyzers/releases)
    - [Changelog](https://github.com/nsubstitute/NSubstitute.Analyzers/blob/1.0.14/ReleaseNotes.md)
    - [Commits](nsubstitute/NSubstitute.Analyzers@1.0.13...1.0.14)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 44982ac
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:02 2020 +0000

    Bump Microsoft.Extensions.Configuration.Json from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.Extensions.Configuration.Json](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 88e8bcc
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:01 2020 +0000

    Bump Microsoft.Azure.WebJobs from 3.0.18 to 3.0.23 in /src

    Bumps [Microsoft.Azure.WebJobs](https://github.com/Azure/azure-webjobs-sdk) from 3.0.18 to 3.0.23.
    - [Release notes](https://github.com/Azure/azure-webjobs-sdk/releases)
    - [Commits](Azure/azure-webjobs-sdk@v3.0.18...v3.0.23)

    Signed-off-by: dependabot[bot] <[email protected]>

commit abd25f0
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:01 2020 +0000

    Bump Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel

    Bumps [Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel](https://github.com/Microsoft/ApplicationInsights-dotnet) from 2.14.0 to 2.16.0.
    - [Release notes](https://github.com/Microsoft/ApplicationInsights-dotnet/releases)
    - [Changelog](https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/CHANGELOG.md)
    - [Commits](microsoft/ApplicationInsights-dotnet@2.14.0...2.16.0)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 86efb3f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:01 2020 +0000

    Bump Microsoft.Extensions.Configuration.EnvironmentVariables in /src

    Bumps [Microsoft.Extensions.Configuration.EnvironmentVariables](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

commit 423f77f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:26:58 2020 +0000

    Bump Microsoft.Extensions.Hosting from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.Extensions.Hosting](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <[email protected]>

* Release notes

* stop using Dependabot

* clear warnings

Co-authored-by: Alexander Omelchuk <[email protected]>
  • Loading branch information
giuliov and aok-foss authored Dec 12, 2020
1 parent dbdf4b5 commit b20fc52
Show file tree
Hide file tree
Showing 61 changed files with 1,019 additions and 107 deletions.
17 changes: 0 additions & 17 deletions .github/dependabot.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
run: echo ::set-output name=tag_name::${GITHUB_REF/refs\/tags\//}
shell: bash
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected].4
uses: gittools/actions/gitversion/[email protected].7
with:
versionSpec: '5.3.x'
versionSpec: '5.5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected].4
uses: gittools/actions/gitversion/[email protected].7
- name: 'Set version in aggregator-manifest.ini'
run: 'sed -E -i "s/version=.*/version=${{ steps.gitversion.outputs.fullSemVer }}/" ${GITHUB_WORKSPACE}/src/aggregator-function/aggregator-manifest.ini'
shell: bash
Expand Down
32 changes: 13 additions & 19 deletions Next-Release-ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
This is the inital **1.0** release.
This release fixes a number of issues and introduce an additional CLI command.


CLI Commands and Options
========================
* Resolve code analysis warnings.
* Fix incorrect HTTP Header in web hook Subscriptions made by `map.local.rule`.
* Fix incorrect URL in web hook Subscriptions made by `map.local.rule`.
- Removed annoying messages about new version check.
- Deprecation warning on missing `--resourceGroup` option.
- Changed `IDataProtectionProvider.CreateProtector` purpose string to prevent clashes.
- New `update.mappings` command.


Docker and Azure Function Hosting
========================
* Resolve code analysis warnings.
* Fix CS1705 error.
* Support for `Aggregator_AzureDevOpsCertificate` when Azure DevOps is using a certificate issued by non-trusted Certification Authority (e.g.self-signed).
* Better handling of API keys.
- Retry after Http 429 using Polly, address #71.
- Harden Azure resources (see #225).


Rule Language
========================
* New optional `events` directive.
No changes.


Rule Interpreter Engine
========================
* Resolve code analysis warnings.
* Improved some messages.
- Address #185 by removing field when set to null value.
- Impersonation does not work when a rule updates the same work item bug (#206).


Build, Test, Documentation
========================
* Updated to the latest version of NuGet packages except for Function SDK and Logging.
* Stick to `Microsoft.NET.Sdk.Functions` 3.0.3 until they resolve [#465](https://github.com/Azure/azure-functions-vs-build-sdk/issues/465). This locks `Microsoft.Extensions.Logging` to 3.1.6 too.
* Resolve code analysis warnings.
* Fix default branch reference in CI workflow.
* Push docker images to GitHub Container Registry (beta) in addition to Docker Hub.
* Local version number is now `0.0.1-localdev`.
* Fix build badge, added SonarQube badge.
* Trimmed `.dockerignore`.
- Terraform and PowerShell scripts to setup a dev VM.
- Use latest GitVersion.


File Hashes
Expand Down
6 changes: 6 additions & 0 deletions src/aggregator-cli.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{F0E724
win-x64.Dockerfile = win-x64.Dockerfile
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{72427DCE-8A20-45E5-A5E4-781E7E4C1A34}"
ProjectSection(SolutionItems) = preProject
..\Next-Release-ChangeLog.md = ..\Next-Release-ChangeLog.md
..\README.md = ..\README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
13 changes: 13 additions & 0 deletions src/aggregator-cli/ContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace aggregator.cli
{
static class ContextExtensions
{
public static void ResourceGroupDeprecationCheck(this CommandContext ctx, string rg)
{
if (string.IsNullOrWhiteSpace(rg))
{
ctx.Logger.WriteWarning($"Deprecation notice: the resourceGroup option will be mandatory in a future version of Aggregator.");
}
}
}
}
1 change: 1 addition & 0 deletions src/aggregator-cli/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
[assembly: SuppressMessage("Critical Code Smell", "S3966:Objects should not be disposed more than once", Justification = "We dispose only BCL objects and we trust how they implemented Dispose()")]
[assembly: SuppressMessage("Info Code Smell", "S1135:Track uses of \"TODO\" tags", Justification = "Leave markers")]
[assembly: SuppressMessage("Major Code Smell", "S125:Sections of code should not be commented out", Justification = "THey are TODOs")]
[assembly: SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "Do not warn")]
2 changes: 2 additions & 0 deletions src/aggregator-cli/Instances/AggregatorInstances.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ private static async Task<Dictionary<string, string>> UpdateDefaultFilesAsync(Fu
var entry = archive.Entries
.Single(e => string.Equals("aggregator-function.dll", e.Name, StringComparison.OrdinalIgnoreCase));

#pragma warning disable S5042 // Make sure that decompressing this archive file is safe
using (var assemblyStream = entry.Open())
#pragma warning restore S5042 // Make sure that decompressing this archive file is safe
{
await uploadFiles.AddFunctionDefaultFiles(assemblyStream);
}
Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Instances/ConfigureInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
.WithAzureLogon()
.WithDevOpsLogon() // need the token, so we can save it in the app settings
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
var instance = context.Naming.Instance(Name, ResourceGroup);
if (Authentication)
Expand Down
2 changes: 2 additions & 0 deletions src/aggregator-cli/Instances/FunctionRuntimePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ private async Task<SemVersion> GetLocalPackageVersionAsync(string runtimePackage
using (var zip = ZipFile.OpenRead(runtimePackageFile))
{
var manifestEntry = zip.GetEntry("aggregator-manifest.ini");
#pragma warning disable S5042 // Make sure that decompressing this archive file is safe
using (var byteStream = manifestEntry.Open())
#pragma warning restore S5042 // Make sure that decompressing this archive file is safe
using (var reader = new StreamReader(byteStream))
{
var content = await reader.ReadToEndAsync();
Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Instances/InstallInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
.WithAzureLogon()
.WithDevOpsLogon() // need the token, so we can save it in the app settings
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
var instance = context.Naming.GetInstanceCreateNames(Name, ResourceGroup);
bool ok = await instances.AddAsync(instance, Location, RequiredVersion, SourceUrl, tuning, cancellationToken);
Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Instances/ListInstancesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
var context = await Context
.WithAzureLogon()
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
if (!string.IsNullOrEmpty(Location))
{
Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Instances/StreamLogsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
var context = await Context
.WithAzureLogon()
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
var instance = context.Naming.Instance(Instance, ResourceGroup);
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
bool ok = await instances.StreamLogsAsync(instance, cancellationToken);
Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Instances/UninstallInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
.WithAzureLogon()
.WithDevOpsLogon()
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);

var instance = context.Naming.Instance(Name, ResourceGroup);

Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Instances/UpdateInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
var context = await Context
.WithAzureLogon()
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);

var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
var instance = context.Naming.Instance(Instance, ResourceGroup);
Expand Down
14 changes: 9 additions & 5 deletions src/aggregator-cli/Instances/instance-template.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"functionAppName": {
Expand Down Expand Up @@ -84,12 +84,15 @@
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('storageAccountName')]",
"apiVersion": "2016-12-01",
"apiVersion": "2019-06-01",
"location": "[parameters('webLocation')]",
"kind": "Storage",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"properties": {
"supportsHttpsTrafficOnly": true
},
"tags": {
"aggregatorVersion": "[parameters('aggregatorVersion')]"
}
Expand All @@ -111,7 +114,7 @@
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2016-09-01",
"apiVersion": "2019-08-01",
"name": "[parameters('hostingPlanName')]",
"location": "[parameters('webLocation')]",
"properties": {
Expand All @@ -125,7 +128,7 @@
}
},
{
"apiVersion": "2015-08-01",
"apiVersion": "2019-08-01",
"type": "Microsoft.Web/sites",
"name": "[parameters('functionAppName')]",
"location": "[parameters('webLocation')]",
Expand Down Expand Up @@ -195,7 +198,8 @@
"value": "Files"
}
]
}
},
"httpsOnly": true
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/aggregator-cli/Logon/MyProtector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MyProtector
// the 'provider' parameter is provided by DI
public MyProtector(IDataProtectionProvider provider)
{
_protector = provider.CreateProtector("Contoso.MyClass.v1");
_protector = provider.CreateProtector("Aggregator.CLI.Logon.Protector.v1");
}

public string Encrypt(string input) => _protector.Protect(input);
Expand Down
96 changes: 90 additions & 6 deletions src/aggregator-cli/Mappings/AggregatorMappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ internal enum RemoveOutcome
Failed = 1
}

internal enum UpdateOutcome
{
Succeeded = 0,
NotFound = 2,
Failed = 1
}

internal class AggregatorMappings
{
private readonly VssConnection devops;
Expand Down Expand Up @@ -65,17 +72,94 @@ internal async Task<IEnumerable<MappingOutputData>> ListAsync(InstanceName insta
{
continue;
}
// HACK need to factor the URL<->rule_name
Uri ruleUrl = new Uri(subscription.ConsumerInputs.GetValue("url", MagicConstants.MissingUrl));
string ruleName = ruleUrl.Segments.LastOrDefault() ?? string.Empty;
string ruleFullName = $"{naming.FromFunctionAppUrl(ruleUrl).PlainName}/{ruleName}";
string ruleFullName = GetRuleFullName(ruleUrl);
result.Add(
new MappingOutputData(instance, ruleFullName, ruleUrl.IsImpersonationEnabled(), foundProject.Name, subscription.EventType, subscription.Status.ToString())
);
}
return result;
}

private string GetRuleFullName(Uri ruleUri)
{
// HACK need to factor the URL<->rule_name
string ruleName = ruleUri.Segments.LastOrDefault() ?? string.Empty;
string ruleFullName = $"{naming.FromFunctionAppUrl(ruleUri).PlainName}/{ruleName}";
return ruleFullName;
}

internal async Task<UpdateOutcome> RemapAsync(InstanceName sourceInstance, InstanceName destInstance, string projectName, CancellationToken cancellationToken)
{
logger.WriteVerbose($"Searching aggregator mappings in Azure DevOps...");
var serviceHooksClient = devops.GetClient<ServiceHooksPublisherHttpClient>();
var subscriptions = await serviceHooksClient.QuerySubscriptionsAsync();
var filteredSubs = subscriptions.Where(s
=> s.PublisherId == DevOpsEvents.PublisherId
&& s.ConsumerInputs.GetValue("url", "").StartsWith(
sourceInstance.FunctionAppUrl, StringComparison.OrdinalIgnoreCase));
var projectClient = devops.GetClient<ProjectHttpClient>();
var projects = await projectClient.GetProjects();
var projectsDict = projects.ToDictionary(p => p.Id);

int processedCount = 0;
int succeededCount = 0;

foreach (var subscription in filteredSubs)
{
var foundProject = projectsDict[
new Guid(subscription.PublisherInputs["projectId"])
];
if (!string.IsNullOrEmpty(projectName) && foundProject.Name != projectName)
{
logger.WriteInfo($"Skipping mapping {subscription.Id} in project {projectName}");
continue;
}
if (subscription.Status != SubscriptionStatus.Enabled && subscription.Status != SubscriptionStatus.OnProbation)
{
logger.WriteInfo($"Skipping mapping {subscription.Id} because has status {subscription.Status.ToString()}");
continue;
}

processedCount++;

Uri ruleUrl = new Uri(subscription.ConsumerInputs.GetValue("url", MagicConstants.MissingUrl));
string ruleName = ruleUrl.Segments.LastOrDefault() ?? string.Empty;

var rules = new AggregatorRules(azure, logger);
try
{
var destRuleTarget = await rules.GetInvocationUrlAndKey(destInstance, ruleName, cancellationToken);
// PATCH the object
subscription.ConsumerInputs["url"] = destRuleTarget.url.AbsoluteUri;
subscription.ConsumerInputs["httpHeaders"] = $"{MagicConstants.AzureFunctionKeyHeaderName}:{destRuleTarget.key}";

logger.WriteVerbose($"Replacing {subscription.EventType} mapping from {ruleUrl.AbsoluteUri} to {subscription.Url}...");
try
{
var newSubscription = await serviceHooksClient.UpdateSubscriptionAsync(subscription);
logger.WriteInfo($"Event subscription {newSubscription.Id} updated.");
succeededCount++;
}
catch (Exception ex)
{
logger.WriteError($"Failed updating subscription {subscription.Id}: {ex.Message}.");
}
}
catch (Exception ex)
{
logger.WriteError($"Destination rule {destInstance.PlainName}/{ruleName} does not exists or cannot retrieve key: {ex.Message}.");
}

}

#pragma warning disable S3358 // Extract this nested ternary operation into an independent statement
return processedCount == 0 ? UpdateOutcome.NotFound
: (processedCount > succeededCount) ? UpdateOutcome.Failed
: UpdateOutcome.Succeeded;
#pragma warning restore S3358 // Extract this nested ternary operation into an independent statement
}

internal async Task<Guid> AddAsync(string projectName, string @event, EventFilters filters, InstanceName instance, string ruleName, bool impersonateExecution, CancellationToken cancellationToken)
{
async Task<(Uri, string)> RetrieveAzureFunctionUrl(string _ruleName, CancellationToken _cancellationToken)
Expand All @@ -84,7 +168,7 @@ internal async Task<Guid> AddAsync(string projectName, string @event, EventFilte
return await rules.GetInvocationUrlAndKey(instance, _ruleName, _cancellationToken);
}

return await CoreAddAsync(projectName, @event, filters, ruleName, impersonateExecution, RetrieveAzureFunctionUrl, "x-functions-key", cancellationToken);
return await CoreAddAsync(projectName, @event, filters, ruleName, impersonateExecution, RetrieveAzureFunctionUrl, MagicConstants.AzureFunctionKeyHeaderName, cancellationToken);
}

internal async Task<Guid> AddFromUrlAsync(string projectName, string @event, EventFilters filters, Uri targetUrl, string ruleName, bool impersonateExecution, CancellationToken cancellationToken)
Expand All @@ -98,7 +182,7 @@ internal async Task<Guid> AddFromUrlAsync(string projectName, string @event, Eve
string userManagedPassword = Environment.GetEnvironmentVariable(MagicConstants.EnvironmentVariable_SharedSecret);
if (string.IsNullOrEmpty(userManagedPassword))
{
throw new ApplicationException($"{MagicConstants.EnvironmentVariable_SharedSecret} environment variable is required for this command");
throw new InvalidOperationException($"{MagicConstants.EnvironmentVariable_SharedSecret} environment variable is required for this command");
}

string proof = SharedSecret.DeriveFromPassword(userManagedPassword);
Expand Down Expand Up @@ -133,7 +217,7 @@ internal async Task<Guid> AddFromUrlAsync(string projectName, string @event, Eve

if (string.IsNullOrEmpty(apiKey) || apiKey == MagicConstants.InvalidApiKey)
{
throw new ApplicationException("Unable to retrieve API Key, please check Shared secret configuration");
throw new InvalidOperationException("Unable to retrieve API Key, please check Shared secret configuration");
}

var b = new UriBuilder(targetUrl);
Expand Down
1 change: 1 addition & 0 deletions src/aggregator-cli/Mappings/ListMappingsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
var context = await Context
.WithDevOpsLogon()
.BuildAsync(cancellationToken);
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
if (string.IsNullOrEmpty(Instance)
&& string.IsNullOrEmpty(Project))
{
Expand Down
Loading

0 comments on commit b20fc52

Please sign in to comment.