From ec266063f976aaffa8b18615c90c5ae75cf7661c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 31 Mar 2023 21:29:29 +0100 Subject: [PATCH] fix(DoS): specify timeout in Regex ctor This isn't actually a "fix", the method may be slow by design if the source is lazily enumerated. SonarCloud, however, did not like this method not having an explicit timeout. If SonarCloud continues to complain, we'll just shut its mouth masking tape and throw it in the broom closet. --- X10D/src/Text/EnumerableExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/X10D/src/Text/EnumerableExtensions.cs b/X10D/src/Text/EnumerableExtensions.cs index c7f4476..c5552b3 100644 --- a/X10D/src/Text/EnumerableExtensions.cs +++ b/X10D/src/Text/EnumerableExtensions.cs @@ -72,7 +72,8 @@ public static class EnumerableExtensions } #endif - var regex = new Regex(pattern, RegexOptions.Compiled | (ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None)); + var options = RegexOptions.Compiled | (ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None); + var regex = new Regex(pattern, options, Regex.InfiniteMatchTimeout); foreach (string item in source) {