Update FileAnalysis.cs
This commit is contained in:
parent
aee8acf60f
commit
e32f496f12
@ -157,20 +157,17 @@ namespace winPEAS.Checks
|
|||||||
Regex rgx;
|
Regex rgx;
|
||||||
bool is_re_match = false;
|
bool is_re_match = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Escape backslashes in the regex string
|
|
||||||
string escapedRegex = regex_str.Trim().Replace(@"\", @"\\");
|
|
||||||
|
|
||||||
// Use "IsMatch" because it supports timeout, if exception is thrown exit the func to avoid ReDoS in "rgx.Matches"
|
// Use "IsMatch" because it supports timeout, if exception is thrown exit the func to avoid ReDoS in "rgx.Matches"
|
||||||
if (caseinsensitive)
|
if (caseinsensitive)
|
||||||
{
|
{
|
||||||
is_re_match = Regex.IsMatch(text, escapedRegex, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(120));
|
is_re_match = Regex.IsMatch(text, regex_str.Trim(), RegexOptions.IgnoreCase, TimeSpan.FromSeconds(120));
|
||||||
rgx = new Regex(escapedRegex, RegexOptions.IgnoreCase);
|
rgx = new Regex(regex_str.Trim(), RegexOptions.IgnoreCase);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
is_re_match = Regex.IsMatch(text, escapedRegex, RegexOptions.None, TimeSpan.FromSeconds(120));
|
is_re_match = Regex.IsMatch(text, regex_str.Trim(), RegexOptions.None, TimeSpan.FromSeconds(120));
|
||||||
rgx = new Regex(escapedRegex);
|
rgx = new Regex(regex_str.Trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RegexMatchTimeoutException e)
|
catch (RegexMatchTimeoutException e)
|
||||||
|
Loading…
Reference in New Issue
Block a user