Skip to content

Commit

Permalink
Add UTs for S6444 (#8614)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Jan 25, 2024
1 parent 0156ceb commit e11a383
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ public class SpecifyTimeoutOnRegexTest
[TestMethod]
public void SpecifyTimeoutOnRegex_CSharp8() =>
builderCS.AddPaths("SpecifyTimeoutOnRegex.CSharp9.cs")
.WithOptions(ParseOptionsHelper.FromCSharp9)
.Verify();
.WithOptions(ParseOptionsHelper.FromCSharp9)
.Verify();

[TestMethod]
public void SpecifyTimeoutOnRegex_DefaultMatchTimeout() =>
builderCS.AddPaths("SpecifyTimeoutOnRegex.DefaultMatchTimeout.cs")
.WithTopLevelStatements()
.Verify();

[TestMethod]
public void SpecifyTimeoutOnRegex_VB() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Text.RegularExpressions;
using System;

AppDomain.CurrentDomain.SetData("REGEX_DEFAULT_MATCH_TIMEOUT", TimeSpan.FromMilliseconds(100));

void RegexPattern(string input)
{
_ = new Regex(".+@.+", RegexOptions.None); // Noncompliant, FP REGEX_DEFAULT_MATCH_TIMEOUT is set in the AppDomain
_ = Regex.IsMatch(input, "[0-9]+"); // Noncompliant, FP REGEX_DEFAULT_MATCH_TIMEOUT is set in the AppDomain
}

0 comments on commit e11a383

Please sign in to comment.