28 lines
904 B
Plaintext
28 lines
904 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Sensitive Code Example
|
||
|
|
||
|
[source,vbnet]
|
||
|
----
|
||
|
Public Sub RegexPattern(Input As String)
|
||
|
Dim EmailPattern As New Regex(".+@.+", RegexOptions.None)
|
||
|
Dim IsNumber as Boolean = Regex.IsMatch(Input, "[0-9]+")
|
||
|
Dim IsLetterA as Boolean = Regex.IsMatch(Input, "(a+)+")
|
||
|
End Sub
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
[source,vbnet]
|
||
|
----
|
||
|
Public Sub RegexPattern(Input As String)
|
||
|
Dim EmailPattern As New Regex(".+@.+", RegexOptions.None, TimeSpan.FromMilliseconds(100))
|
||
|
Dim IsNumber as Boolean = Regex.IsMatch(Input, "[0-9]+", RegexOptions.None, TimeSpan.FromMilliseconds(100))
|
||
|
Dim IsLetterA As Boolean = Regex.IsMatch(Input, "(a+)+", RegexOptions.NonBacktracking) '.Net 7 And above
|
||
|
AppDomain.CurrentDomain.SetData("REGEX_DEFAULT_MATCH_TIMEOUT", TimeSpan.FromMilliseconds(100)) 'process-wide setting
|
||
|
End Sub
|
||
|
----
|
||
|
|
||
|
include::../see.adoc[]
|
||
|
|
||
|
include::../rspecator.adoc[]
|