Skip to content

Commit

Permalink
fix(DoS): specify timeout in Regex ctor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oliverbooth committed Mar 31, 2023
1 parent e70781e commit ec26606
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion X10D/src/Text/EnumerableExtensions.cs
Expand Up @@ -72,7 +72,8 @@ public static IEnumerable<string> Grep(this IEnumerable<string> source, string p
}
#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)
{
Expand Down

0 comments on commit ec26606

Please sign in to comment.