mirror of
https://github.com/Radarr/Radarr
synced 2026-01-21 23:14:06 +01:00
fix(security): add regex timeouts for ReDoS prevention (#97)
Add TimeSpan.FromSeconds(1) timeout to remaining regex patterns: - FileNameBuilder.cs: EditionOrdinalRegex, EditionUppercaseRegex - Parser.cs: SlugSpaceRegex, SlugInvalidCharsRegex, SlugDuplicateDefaultRegex Clears final 5 SonarCloud security hotspots for 100% review coverage Co-authored-by: admin <admin@ardentleatherworks.com>
This commit is contained in:
parent
9bf299c196
commit
d8c69e87e2
2 changed files with 5 additions and 5 deletions
|
|
@ -57,8 +57,8 @@ public class FileNameBuilder : IBuildFileNames
|
|||
private static readonly Regex ReservedDeviceNamesRegex = new Regex(@"^(?:aux|com[1-9]|con|lpt[1-9]|nul|prn)\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
// Edition token regex patterns
|
||||
private static readonly Regex EditionOrdinalRegex = new Regex(@"((?:\b|_)\d{1,3}(?:st|th|rd|nd)(?:\b|_))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex EditionUppercaseRegex = new Regex(@"((?:\b|_)(?:IMAX|3D|SDR|HDR|DV)(?:\b|_))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex EditionOrdinalRegex = new Regex(@"((?:\b|_)\d{1,3}(?:st|th|rd|nd)(?:\b|_))", RegexOptions.Compiled | RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));
|
||||
private static readonly Regex EditionUppercaseRegex = new Regex(@"((?:\b|_)(?:IMAX|3D|SDR|HDR|DV)(?:\b|_))", RegexOptions.Compiled | RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));
|
||||
|
||||
// generated from https://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
|
||||
public static readonly ImmutableDictionary<string, string> Iso639BTMap = new Dictionary<string, string>
|
||||
|
|
|
|||
|
|
@ -138,9 +138,9 @@ public static class Parser
|
|||
private static readonly Regex RequestInfoRegex = new Regex(@"^(?:\[.+?\])+", RegexOptions.Compiled);
|
||||
|
||||
// ToUrlSlug regex patterns
|
||||
private static readonly Regex SlugSpaceRegex = new Regex(@"\s", RegexOptions.Compiled);
|
||||
private static readonly Regex SlugInvalidCharsRegex = new Regex(@"[^a-z0-9\s-_]", RegexOptions.Compiled);
|
||||
private static readonly Regex SlugDuplicateDefaultRegex = new Regex(@"([-_]){2,}", RegexOptions.Compiled);
|
||||
private static readonly Regex SlugSpaceRegex = new Regex(@"\s", RegexOptions.Compiled, TimeSpan.FromSeconds(1));
|
||||
private static readonly Regex SlugInvalidCharsRegex = new Regex(@"[^a-z0-9\s-_]", RegexOptions.Compiled, TimeSpan.FromSeconds(1));
|
||||
private static readonly Regex SlugDuplicateDefaultRegex = new Regex(@"([-_]){2,}", RegexOptions.Compiled, TimeSpan.FromSeconds(1));
|
||||
|
||||
private static readonly string[] Numbers = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue