Skip to content

Commit b20fc52

Browse files
giuliovaok-foss
andauthored
Release/1.0.x (#226)
* 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]>
1 parent dbdf4b5 commit b20fc52

File tree

61 files changed

+1019
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1019
-107
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/build-and-deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ jobs:
3939
run: echo ::set-output name=tag_name::${GITHUB_REF/refs\/tags\//}
4040
shell: bash
4141
- name: Install GitVersion
42-
uses: gittools/actions/gitversion/[email protected].4
42+
uses: gittools/actions/gitversion/[email protected].7
4343
with:
44-
versionSpec: '5.3.x'
44+
versionSpec: '5.5.x'
4545
- name: Use GitVersion
4646
id: gitversion # step id used as reference for output values
47-
uses: gittools/actions/gitversion/[email protected].4
47+
uses: gittools/actions/gitversion/[email protected].7
4848
- name: 'Set version in aggregator-manifest.ini'
4949
run: 'sed -E -i "s/version=.*/version=${{ steps.gitversion.outputs.fullSemVer }}/" ${GITHUB_WORKSPACE}/src/aggregator-function/aggregator-manifest.ini'
5050
shell: bash

Next-Release-ChangeLog.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
1-
This is the inital **1.0** release.
1+
This release fixes a number of issues and introduce an additional CLI command.
2+
23

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

911

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

1717

1818
Rule Language
1919
========================
20-
* New optional `events` directive.
20+
No changes.
2121

2222

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

2828

2929
Build, Test, Documentation
3030
========================
31-
* Updated to the latest version of NuGet packages except for Function SDK and Logging.
32-
* 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.
33-
* Resolve code analysis warnings.
34-
* Fix default branch reference in CI workflow.
35-
* Push docker images to GitHub Container Registry (beta) in addition to Docker Hub.
36-
* Local version number is now `0.0.1-localdev`.
37-
* Fix build badge, added SonarQube badge.
38-
* Trimmed `.dockerignore`.
31+
- Terraform and PowerShell scripts to setup a dev VM.
32+
- Use latest GitVersion.
3933

4034

4135
File Hashes

src/aggregator-cli.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{F0E724
4545
win-x64.Dockerfile = win-x64.Dockerfile
4646
EndProjectSection
4747
EndProject
48+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{72427DCE-8A20-45E5-A5E4-781E7E4C1A34}"
49+
ProjectSection(SolutionItems) = preProject
50+
..\Next-Release-ChangeLog.md = ..\Next-Release-ChangeLog.md
51+
..\README.md = ..\README.md
52+
EndProjectSection
53+
EndProject
4854
Global
4955
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5056
Debug|Any CPU = Debug|Any CPU
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace aggregator.cli
2+
{
3+
static class ContextExtensions
4+
{
5+
public static void ResourceGroupDeprecationCheck(this CommandContext ctx, string rg)
6+
{
7+
if (string.IsNullOrWhiteSpace(rg))
8+
{
9+
ctx.Logger.WriteWarning($"Deprecation notice: the resourceGroup option will be mandatory in a future version of Aggregator.");
10+
}
11+
}
12+
}
13+
}

src/aggregator-cli/GlobalSuppressions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
[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()")]
99
[assembly: SuppressMessage("Info Code Smell", "S1135:Track uses of \"TODO\" tags", Justification = "Leave markers")]
1010
[assembly: SuppressMessage("Major Code Smell", "S125:Sections of code should not be commented out", Justification = "THey are TODOs")]
11+
[assembly: SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "Do not warn")]

src/aggregator-cli/Instances/AggregatorInstances.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ private static async Task<Dictionary<string, string>> UpdateDefaultFilesAsync(Fu
338338
var entry = archive.Entries
339339
.Single(e => string.Equals("aggregator-function.dll", e.Name, StringComparison.OrdinalIgnoreCase));
340340

341+
#pragma warning disable S5042 // Make sure that decompressing this archive file is safe
341342
using (var assemblyStream = entry.Open())
343+
#pragma warning restore S5042 // Make sure that decompressing this archive file is safe
342344
{
343345
await uploadFiles.AddFunctionDefaultFiles(assemblyStream);
344346
}

src/aggregator-cli/Instances/ConfigureInstanceCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
3535
.WithAzureLogon()
3636
.WithDevOpsLogon() // need the token, so we can save it in the app settings
3737
.BuildAsync(cancellationToken);
38+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
3839
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
3940
var instance = context.Naming.Instance(Name, ResourceGroup);
4041
if (Authentication)

src/aggregator-cli/Instances/FunctionRuntimePackage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ private async Task<SemVersion> GetLocalPackageVersionAsync(string runtimePackage
329329
using (var zip = ZipFile.OpenRead(runtimePackageFile))
330330
{
331331
var manifestEntry = zip.GetEntry("aggregator-manifest.ini");
332+
#pragma warning disable S5042 // Make sure that decompressing this archive file is safe
332333
using (var byteStream = manifestEntry.Open())
334+
#pragma warning restore S5042 // Make sure that decompressing this archive file is safe
333335
using (var reader = new StreamReader(byteStream))
334336
{
335337
var content = await reader.ReadToEndAsync();

src/aggregator-cli/Instances/InstallInstanceCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
6767
.WithAzureLogon()
6868
.WithDevOpsLogon() // need the token, so we can save it in the app settings
6969
.BuildAsync(cancellationToken);
70+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
7071
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
7172
var instance = context.Naming.GetInstanceCreateNames(Name, ResourceGroup);
7273
bool ok = await instances.AddAsync(instance, Location, RequiredVersion, SourceUrl, tuning, cancellationToken);

src/aggregator-cli/Instances/ListInstancesCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
2020
var context = await Context
2121
.WithAzureLogon()
2222
.BuildAsync(cancellationToken);
23+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
2324
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
2425
if (!string.IsNullOrEmpty(Location))
2526
{

src/aggregator-cli/Instances/StreamLogsCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
1818
var context = await Context
1919
.WithAzureLogon()
2020
.BuildAsync(cancellationToken);
21+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
2122
var instance = context.Naming.Instance(Instance, ResourceGroup);
2223
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
2324
bool ok = await instances.StreamLogsAsync(instance, cancellationToken);

src/aggregator-cli/Instances/UninstallInstanceCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
2828
.WithAzureLogon()
2929
.WithDevOpsLogon()
3030
.BuildAsync(cancellationToken);
31+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
3132

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

src/aggregator-cli/Instances/UpdateInstanceCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
2727
var context = await Context
2828
.WithAzureLogon()
2929
.BuildAsync(cancellationToken);
30+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
3031

3132
var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
3233
var instance = context.Naming.Instance(Instance, ResourceGroup);

src/aggregator-cli/Instances/instance-template.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
44
"parameters": {
55
"functionAppName": {
@@ -84,12 +84,15 @@
8484
{
8585
"type": "Microsoft.Storage/storageAccounts",
8686
"name": "[parameters('storageAccountName')]",
87-
"apiVersion": "2016-12-01",
87+
"apiVersion": "2019-06-01",
8888
"location": "[parameters('webLocation')]",
8989
"kind": "Storage",
9090
"sku": {
9191
"name": "[parameters('storageAccountType')]"
9292
},
93+
"properties": {
94+
"supportsHttpsTrafficOnly": true
95+
},
9396
"tags": {
9497
"aggregatorVersion": "[parameters('aggregatorVersion')]"
9598
}
@@ -111,7 +114,7 @@
111114
},
112115
{
113116
"type": "Microsoft.Web/serverfarms",
114-
"apiVersion": "2016-09-01",
117+
"apiVersion": "2019-08-01",
115118
"name": "[parameters('hostingPlanName')]",
116119
"location": "[parameters('webLocation')]",
117120
"properties": {
@@ -125,7 +128,7 @@
125128
}
126129
},
127130
{
128-
"apiVersion": "2015-08-01",
131+
"apiVersion": "2019-08-01",
129132
"type": "Microsoft.Web/sites",
130133
"name": "[parameters('functionAppName')]",
131134
"location": "[parameters('webLocation')]",
@@ -195,7 +198,8 @@
195198
"value": "Files"
196199
}
197200
]
198-
}
201+
},
202+
"httpsOnly": true
199203
}
200204
}
201205
]

src/aggregator-cli/Logon/MyProtector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MyProtector
99
// the 'provider' parameter is provided by DI
1010
public MyProtector(IDataProtectionProvider provider)
1111
{
12-
_protector = provider.CreateProtector("Contoso.MyClass.v1");
12+
_protector = provider.CreateProtector("Aggregator.CLI.Logon.Protector.v1");
1313
}
1414

1515
public string Encrypt(string input) => _protector.Protect(input);

src/aggregator-cli/Mappings/AggregatorMappings.cs

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ internal enum RemoveOutcome
2222
Failed = 1
2323
}
2424

25+
internal enum UpdateOutcome
26+
{
27+
Succeeded = 0,
28+
NotFound = 2,
29+
Failed = 1
30+
}
31+
2532
internal class AggregatorMappings
2633
{
2734
private readonly VssConnection devops;
@@ -65,17 +72,94 @@ internal async Task<IEnumerable<MappingOutputData>> ListAsync(InstanceName insta
6572
{
6673
continue;
6774
}
68-
// HACK need to factor the URL<->rule_name
6975
Uri ruleUrl = new Uri(subscription.ConsumerInputs.GetValue("url", MagicConstants.MissingUrl));
70-
string ruleName = ruleUrl.Segments.LastOrDefault() ?? string.Empty;
71-
string ruleFullName = $"{naming.FromFunctionAppUrl(ruleUrl).PlainName}/{ruleName}";
76+
string ruleFullName = GetRuleFullName(ruleUrl);
7277
result.Add(
7378
new MappingOutputData(instance, ruleFullName, ruleUrl.IsImpersonationEnabled(), foundProject.Name, subscription.EventType, subscription.Status.ToString())
7479
);
7580
}
7681
return result;
7782
}
7883

84+
private string GetRuleFullName(Uri ruleUri)
85+
{
86+
// HACK need to factor the URL<->rule_name
87+
string ruleName = ruleUri.Segments.LastOrDefault() ?? string.Empty;
88+
string ruleFullName = $"{naming.FromFunctionAppUrl(ruleUri).PlainName}/{ruleName}";
89+
return ruleFullName;
90+
}
91+
92+
internal async Task<UpdateOutcome> RemapAsync(InstanceName sourceInstance, InstanceName destInstance, string projectName, CancellationToken cancellationToken)
93+
{
94+
logger.WriteVerbose($"Searching aggregator mappings in Azure DevOps...");
95+
var serviceHooksClient = devops.GetClient<ServiceHooksPublisherHttpClient>();
96+
var subscriptions = await serviceHooksClient.QuerySubscriptionsAsync();
97+
var filteredSubs = subscriptions.Where(s
98+
=> s.PublisherId == DevOpsEvents.PublisherId
99+
&& s.ConsumerInputs.GetValue("url", "").StartsWith(
100+
sourceInstance.FunctionAppUrl, StringComparison.OrdinalIgnoreCase));
101+
var projectClient = devops.GetClient<ProjectHttpClient>();
102+
var projects = await projectClient.GetProjects();
103+
var projectsDict = projects.ToDictionary(p => p.Id);
104+
105+
int processedCount = 0;
106+
int succeededCount = 0;
107+
108+
foreach (var subscription in filteredSubs)
109+
{
110+
var foundProject = projectsDict[
111+
new Guid(subscription.PublisherInputs["projectId"])
112+
];
113+
if (!string.IsNullOrEmpty(projectName) && foundProject.Name != projectName)
114+
{
115+
logger.WriteInfo($"Skipping mapping {subscription.Id} in project {projectName}");
116+
continue;
117+
}
118+
if (subscription.Status != SubscriptionStatus.Enabled && subscription.Status != SubscriptionStatus.OnProbation)
119+
{
120+
logger.WriteInfo($"Skipping mapping {subscription.Id} because has status {subscription.Status.ToString()}");
121+
continue;
122+
}
123+
124+
processedCount++;
125+
126+
Uri ruleUrl = new Uri(subscription.ConsumerInputs.GetValue("url", MagicConstants.MissingUrl));
127+
string ruleName = ruleUrl.Segments.LastOrDefault() ?? string.Empty;
128+
129+
var rules = new AggregatorRules(azure, logger);
130+
try
131+
{
132+
var destRuleTarget = await rules.GetInvocationUrlAndKey(destInstance, ruleName, cancellationToken);
133+
// PATCH the object
134+
subscription.ConsumerInputs["url"] = destRuleTarget.url.AbsoluteUri;
135+
subscription.ConsumerInputs["httpHeaders"] = $"{MagicConstants.AzureFunctionKeyHeaderName}:{destRuleTarget.key}";
136+
137+
logger.WriteVerbose($"Replacing {subscription.EventType} mapping from {ruleUrl.AbsoluteUri} to {subscription.Url}...");
138+
try
139+
{
140+
var newSubscription = await serviceHooksClient.UpdateSubscriptionAsync(subscription);
141+
logger.WriteInfo($"Event subscription {newSubscription.Id} updated.");
142+
succeededCount++;
143+
}
144+
catch (Exception ex)
145+
{
146+
logger.WriteError($"Failed updating subscription {subscription.Id}: {ex.Message}.");
147+
}
148+
}
149+
catch (Exception ex)
150+
{
151+
logger.WriteError($"Destination rule {destInstance.PlainName}/{ruleName} does not exists or cannot retrieve key: {ex.Message}.");
152+
}
153+
154+
}
155+
156+
#pragma warning disable S3358 // Extract this nested ternary operation into an independent statement
157+
return processedCount == 0 ? UpdateOutcome.NotFound
158+
: (processedCount > succeededCount) ? UpdateOutcome.Failed
159+
: UpdateOutcome.Succeeded;
160+
#pragma warning restore S3358 // Extract this nested ternary operation into an independent statement
161+
}
162+
79163
internal async Task<Guid> AddAsync(string projectName, string @event, EventFilters filters, InstanceName instance, string ruleName, bool impersonateExecution, CancellationToken cancellationToken)
80164
{
81165
async Task<(Uri, string)> RetrieveAzureFunctionUrl(string _ruleName, CancellationToken _cancellationToken)
@@ -84,7 +168,7 @@ internal async Task<Guid> AddAsync(string projectName, string @event, EventFilte
84168
return await rules.GetInvocationUrlAndKey(instance, _ruleName, _cancellationToken);
85169
}
86170

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

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

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

134218
if (string.IsNullOrEmpty(apiKey) || apiKey == MagicConstants.InvalidApiKey)
135219
{
136-
throw new ApplicationException("Unable to retrieve API Key, please check Shared secret configuration");
220+
throw new InvalidOperationException("Unable to retrieve API Key, please check Shared secret configuration");
137221
}
138222

139223
var b = new UriBuilder(targetUrl);

src/aggregator-cli/Mappings/ListMappingsCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal override async Task<int> RunAsync(CancellationToken cancellationToken)
2222
var context = await Context
2323
.WithDevOpsLogon()
2424
.BuildAsync(cancellationToken);
25+
context.ResourceGroupDeprecationCheck(this.ResourceGroup);
2526
if (string.IsNullOrEmpty(Instance)
2627
&& string.IsNullOrEmpty(Project))
2728
{

0 commit comments

Comments
 (0)