diff --git a/src/WorkflowManager/ConditionsResolver/Parser/ConditionalParameterParser.cs b/src/WorkflowManager/ConditionsResolver/Parser/ConditionalParameterParser.cs index c0765c6e4..da89cbf5e 100644 --- a/src/WorkflowManager/ConditionsResolver/Parser/ConditionalParameterParser.cs +++ b/src/WorkflowManager/ConditionsResolver/Parser/ConditionalParameterParser.cs @@ -51,7 +51,7 @@ public class ConditionalParameterParser : IConditionalParameterParser private readonly IPayloadService _payloadService; private readonly IWorkflowService _workflowService; - private readonly Regex _squigglyBracketsRegex = new Regex(@"\{{(.*?)\}}"); + private readonly Regex _squigglyBracketsRegex = new(@"\{{(.*?)\}}", RegexOptions.None, matchTimeout: TimeSpan.FromSeconds(2)); private WorkflowInstance? _workflowInstance = null; private string? _workflowInstanceId = null; diff --git a/src/WorkflowManager/ConditionsResolver/Resovler/ConditionalGroup.cs b/src/WorkflowManager/ConditionsResolver/Resovler/ConditionalGroup.cs index d10f9d0ae..389a0975b 100644 --- a/src/WorkflowManager/ConditionsResolver/Resovler/ConditionalGroup.cs +++ b/src/WorkflowManager/ConditionsResolver/Resovler/ConditionalGroup.cs @@ -38,13 +38,13 @@ public class ConditionalGroup public int GroupedLogical { get; set; } = 1; - public Regex FindAnds { get; } = new Regex(@"([\s]and[\s]|[\s]AND[\s]|[\s]And[\s])"); + public Regex FindAnds { get; } = new(@"([\s]and[\s]|[\s]AND[\s]|[\s]And[\s])", RegexOptions.None, matchTimeout: TimeSpan.FromSeconds(2)); - public Regex FindOrs { get; } = new Regex(@"([\s]or[\s]|[\s]OR[\s]|[\s]Or[\s])"); + public Regex FindOrs { get; } = new(@"([\s]or[\s]|[\s]OR[\s]|[\s]Or[\s])", RegexOptions.None, matchTimeout: TimeSpan.FromSeconds(2)); - public Regex FindBrackets { get; } = new Regex(@"((? FindOrs.SplitOnce(input); diff --git a/src/WorkflowManager/WorkflowManager/Validators/WorkflowValidator.cs b/src/WorkflowManager/WorkflowManager/Validators/WorkflowValidator.cs index c1942d524..52e21ae62 100644 --- a/src/WorkflowManager/WorkflowManager/Validators/WorkflowValidator.cs +++ b/src/WorkflowManager/WorkflowManager/Validators/WorkflowValidator.cs @@ -270,7 +270,7 @@ private async Task ValidateWorkflowSpec(Workflow workflow) } var taskIds = workflow.Tasks.Select(t => t.Id); - var pattern = new Regex(@"^[a-zA-Z0-9-_]+$"); + var pattern = new Regex(@"^[a-zA-Z0-9-_]+$", RegexOptions.None, matchTimeout: TimeSpan.FromSeconds(2)); foreach (var taskId in taskIds) { if (pattern.IsMatch(taskId) is false) diff --git a/tests/UnitTests/ConditionsResolver.Tests/Resolver/RegexExtensionsTests.cs b/tests/UnitTests/ConditionsResolver.Tests/Resolver/RegexExtensionsTests.cs index d33e668c2..d1588338f 100644 --- a/tests/UnitTests/ConditionsResolver.Tests/Resolver/RegexExtensionsTests.cs +++ b/tests/UnitTests/ConditionsResolver.Tests/Resolver/RegexExtensionsTests.cs @@ -30,7 +30,7 @@ public class RegexExtensionsTests [InlineData(new string[] { "test ", "( test( test" }, "test ( test( test")] public void Regex_WhenSplitOnce_ShouldOnlyHaveArrayOfTwo(string[] expected, string stringToSplit) { - var regexFindBrackets = new Regex(@"((?(() => regexFindBrackets.SplitOnce(null)); #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.