From e966f62f29a2cb62edfaf4fd40e2b00fd715f0bf Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 26 Apr 2024 20:07:34 +0200 Subject: [PATCH] Update packages (#5286) * bumped versions to fix dependency vulnerabilities (#5256) * Update patch version in GitHub workflows The version number used in the branch checking step of the GitHub workflows has been updated. Instead of scanning for the branch containing the patch version 3.1.2, it now scans for the branch that contains version 3.1.3. This change is aligned with the updated product version. * Update git branch grep pattern in workflow file The git grep pattern has been corrected to properly identify tagged versions in the GitHub Actions workflow. The correction ensures that the workflow script fetches the right branches as per the release tag instead of patch. * Update grep command in packages workflow The grep command used in the 'packages.yml' GitHub workflow was previously looking for the exact 'refs/tags/3.1.3' string. This commit simplifies the command by making it only look for '3.1.3'. This adjustment will streamline the process and potentially prevent issues with branch recognition. * Update package versions and refactor code for Elasticsearch and JavaScript modules Updated versions of numerous packages in the Directory.Packages.props file to their latest stable releases. This includes updates to Elasticsearch, JavaScript, and MongoDB packages among others. Additionally, refactored parts of the code in the WorkflowInstanceConfiguration and JintJavaScriptEvaluator within the Elasticsearch and JavaScript modules, respectively, to improve index management and script preparation. The WorkflowInstanceStore also saw a minor adjustment. --------- Co-authored-by: Steve Taylor --- .github/workflows/packages.yml | 2 +- Directory.Packages.props | 172 +++++++++--------- ...Net.EntityFrameworkCore.PostgresSql.csproj | 2 +- .../Elsa.Api.Common/Abstractions/Endpoints.cs | 5 +- .../WorkflowInstanceConfiguration.cs | 11 +- .../Management/WorkflowInstanceStore.cs | 2 +- .../Services/JintJavaScriptEvaluator.cs | 11 +- src/modules/Elsa.Quartz/Elsa.Quartz.csproj | 4 +- 8 files changed, 108 insertions(+), 101 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 8a8f70cdc..009401d8e 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -50,7 +50,7 @@ jobs: run: | if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - git branch --remote --contains | grep origin/patch/3.1.2 + git branch --remote --contains | grep 3.1.3 else git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* git branch --remote --contains | grep origin/${BRANCH_NAME} diff --git a/Directory.Packages.props b/Directory.Packages.props index 00f95a7a3..aa8a44a80 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,89 +7,89 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - + + + - + - + - - - + + + - + - + - + - - + + - - + + - - - - - - - - + + + + + + + + - - - - + + + + - + - + @@ -107,17 +107,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -125,9 +125,9 @@ - + - + @@ -137,33 +137,33 @@ - - - - - - - - - - - - + + + + + + + + + + + + - + - + - - + + - - - - + + + + \ No newline at end of file diff --git a/samples/aspnet/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql.csproj b/samples/aspnet/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql.csproj index d48196286..b0593ffb9 100644 --- a/samples/aspnet/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql.csproj +++ b/samples/aspnet/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql/Elsa.Samples.AspNet.EntityFrameworkCore.PostgresSql.csproj @@ -1,7 +1,7 @@ - net7.0 + net7.0;net8.0 diff --git a/src/common/Elsa.Api.Common/Abstractions/Endpoints.cs b/src/common/Elsa.Api.Common/Abstractions/Endpoints.cs index afe42e848..79b59896b 100644 --- a/src/common/Elsa.Api.Common/Abstractions/Endpoints.cs +++ b/src/common/Elsa.Api.Common/Abstractions/Endpoints.cs @@ -1,11 +1,12 @@ using FastEndpoints; +using JetBrains.Annotations; namespace Elsa.Abstractions; /// /// An endpoint that maps a request to a response. /// -public abstract class ElsaEndpointWithMapper : EndpointWithMapper where TMapper : notnull, IRequestMapper where TRequest : notnull +public abstract class ElsaEndpointWithMapper : EndpointWithMapper where TMapper : class, IRequestMapper where TRequest : notnull { protected void ConfigurePermissions(params string[] permissions) { @@ -49,7 +50,7 @@ public class ElsaEndpoint : Endpoint w } } -public class ElsaEndpoint : Endpoint where TRequest : notnull, new() where TResponse : notnull where TMapper : IMapper, new() +public class ElsaEndpoint : Endpoint where TRequest : notnull, new() where TResponse : notnull where TMapper : class, IMapper, new() { protected void ConfigurePermissions(params string[] permissions) { diff --git a/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceConfiguration.cs b/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceConfiguration.cs index a59f9f4fe..0891cfca2 100644 --- a/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceConfiguration.cs +++ b/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceConfiguration.cs @@ -1,4 +1,5 @@ using Elastic.Clients.Elasticsearch; +using Elastic.Clients.Elasticsearch.IndexManagement; using Elsa.Elasticsearch.Common; using Elsa.Elasticsearch.Options; using Elsa.Workflows.Management.Entities; @@ -30,10 +31,10 @@ public class WorkflowInstanceConfiguration : IndexConfiguration public override async ValueTask ConfigureClientAsync(ElasticsearchClient client, CancellationToken cancellationToken) { - await client.Indices.CreateAsync( - descriptor => descriptor.Mappings(m => m - .Properties(p => p - .Flattened(d => d.WorkflowState.Properties))), - cancellationToken); + var alias = _options.GetIndexNameFor(); + var indexName = IndexNamingStrategy.GenerateName(alias); + var descriptor = new CreateIndexRequestDescriptor(indexName); + descriptor.Mappings(m => m.Properties(p => p.Flattened(d => d.WorkflowState.Properties))); + await client.Indices.CreateAsync(descriptor, cancellationToken); } } \ No newline at end of file diff --git a/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs b/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs index 6c4a16054..78e673f3f 100644 --- a/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs +++ b/src/modules/Elsa.Elasticsearch/Modules/Management/WorkflowInstanceStore.cs @@ -157,7 +157,7 @@ public class ElasticWorkflowInstanceStore : IWorkflowInstanceStore if (filter.WorkflowSubStatus != null) descriptor = descriptor.Match(m => m.Field(f => f.SubStatus).Query(filter.WorkflowSubStatus.ToString()!)); if (string.IsNullOrWhiteSpace(filter.SearchTerm)) - return descriptor.MatchAll(); + return descriptor.MatchAll(new MatchAllQuery()); return descriptor .QueryString(c => c diff --git a/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs b/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs index a6dff6543..57b3921ce 100644 --- a/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs +++ b/src/modules/Elsa.JavaScript/Services/JintJavaScriptEvaluator.cs @@ -189,9 +189,14 @@ public class JintJavaScriptEvaluator : IJavaScriptEvaluator if (_jintOptions.ScriptCacheTimeout.HasValue) entry.SetAbsoluteExpiration(_jintOptions.ScriptCacheTimeout.Value); - var parser = new JavaScriptParser(new ParserOptions { AllowReturnOutsideFunction = true }); - var script = parser.ParseScript(expression); - return script; + var prepareOptions = new ScriptPreparationOptions + { + ParsingOptions = new ScriptParsingOptions + { + AllowReturnOutsideFunction = true + } + }; + return Engine.PrepareScript(expression, options: prepareOptions); })!; var result = engine.Evaluate(parsedScript); diff --git a/src/modules/Elsa.Quartz/Elsa.Quartz.csproj b/src/modules/Elsa.Quartz/Elsa.Quartz.csproj index c5043a7a3..4498802c4 100644 --- a/src/modules/Elsa.Quartz/Elsa.Quartz.csproj +++ b/src/modules/Elsa.Quartz/Elsa.Quartz.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 Provides integration with the Quartz.NET library and provide am implementation of Elsa's IJobScheduler using Quartz.NET. @@ -15,7 +15,7 @@ - +