@@ -24,6 +24,8 @@ internal class InstrumentationHelper : IInstrumentationHelper
24
24
private readonly IFileSystem _fileSystem ;
25
25
private readonly ISourceRootTranslator _sourceRootTranslator ;
26
26
private ILogger _logger ;
27
+ private static readonly RegexOptions s_regexOptions =
28
+ RegexOptions . Multiline | RegexOptions . Compiled | RegexOptions . IgnoreCase ;
27
29
28
30
public InstrumentationHelper ( IProcessExitHandler processExitHandler , IRetryHelper retryHelper , IFileSystem fileSystem , ILogger logger , ISourceRootTranslator sourceRootTranslator )
29
31
{
@@ -331,7 +333,7 @@ public bool IsValidFilterExpression(string filter)
331
333
if ( filter . EndsWith ( "]" ) )
332
334
return false ;
333
335
334
- if ( new Regex ( @"[^\w*]" ) . IsMatch ( filter . Replace ( "." , "" ) . Replace ( "?" , "" ) . Replace ( "[" , "" ) . Replace ( "]" , "" ) ) )
336
+ if ( new Regex ( @"[^\w*]" , s_regexOptions , TimeSpan . FromSeconds ( 10 ) ) . IsMatch ( filter . Replace ( "." , "" ) . Replace ( "?" , "" ) . Replace ( "[" , "" ) . Replace ( "]" , "" ) ) )
335
337
return false ;
336
338
337
339
return true ;
@@ -358,7 +360,7 @@ public bool IsModuleExcluded(string module, string[] excludeFilters)
358
360
#pragma warning restore IDE0057 // Use range operator
359
361
modulePattern = WildcardToRegex ( modulePattern ) ;
360
362
361
- var regex = new Regex ( modulePattern ) ;
363
+ var regex = new Regex ( modulePattern , s_regexOptions , TimeSpan . FromSeconds ( 10 ) ) ;
362
364
363
365
if ( regex . IsMatch ( module ) )
364
366
return true ;
@@ -387,7 +389,7 @@ public bool IsModuleIncluded(string module, string[] includeFilters)
387
389
388
390
modulePattern = WildcardToRegex ( modulePattern ) ;
389
391
390
- var regex = new Regex ( modulePattern ) ;
392
+ var regex = new Regex ( modulePattern , s_regexOptions , TimeSpan . FromSeconds ( 10 ) ) ;
391
393
392
394
if ( regex . IsMatch ( module ) )
393
395
return true ;
@@ -421,7 +423,7 @@ public bool IsTypeIncluded(string module, string type, string[] includeFilters)
421
423
}
422
424
423
425
public bool IsLocalMethod ( string method )
424
- => new Regex ( WildcardToRegex ( "<*>*__*|*" ) ) . IsMatch ( method ) ;
426
+ => new Regex ( WildcardToRegex ( "<*>*__*|*" ) , s_regexOptions , TimeSpan . FromSeconds ( 10 ) ) . IsMatch ( method ) ;
425
427
426
428
public void SetLogger ( ILogger logger )
427
429
{
@@ -443,7 +445,7 @@ private static bool IsTypeFilterMatch(string module, string type, string[] filte
443
445
typePattern = WildcardToRegex ( typePattern ) ;
444
446
modulePattern = WildcardToRegex ( modulePattern ) ;
445
447
446
- if ( new Regex ( typePattern ) . IsMatch ( type ) && new Regex ( modulePattern ) . IsMatch ( module ) )
448
+ if ( new Regex ( typePattern , s_regexOptions , TimeSpan . FromSeconds ( 10 ) ) . IsMatch ( type ) && new Regex ( modulePattern , s_regexOptions , TimeSpan . FromSeconds ( 10 ) ) . IsMatch ( module ) )
447
449
return true ;
448
450
}
449
451
0 commit comments