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.
This commit is contained in:
Oliver Booth 2023-03-31 21:29:29 +01:00
parent e70781ef0f
commit ec266063f9
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
1 changed files with 2 additions and 1 deletions

View File

@ -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)
{