Skip to content

Commit

Permalink
- increases default regex timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Nov 28, 2023
1 parent 65a0a6b commit 6ef5cec
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/Kiota.Builder/Extensions/OpenApiUrlTreeNodeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public static string GetNodeNamespaceFromPath(this OpenApiUrlTreeNode currentNod
return currentNode.Path.GetNamespaceFromPath(prefix);
}
//{id}, name(idParam={id}), name(idParam='{id}'), name(idParam='{id}',idParam2='{id2}')
[GeneratedRegex(@"(?:\w+)?=?'?\{(?<paramName>\w+)\}'?,?", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"(?:\w+)?=?'?\{(?<paramName>\w+)\}'?,?", RegexOptions.Singleline, 200)]
private static partial Regex PathParametersRegex();
// microsoft.graph.getRoleScopeTagsByIds(ids=@ids)
[GeneratedRegex(@"=@(\w+)", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"=@(\w+)", RegexOptions.Singleline, 200)]
private static partial Regex AtSignPathParameterRegex();
private const char RequestParametersChar = '{';
private const char RequestParametersEndChar = '}';
Expand Down Expand Up @@ -81,7 +81,7 @@ public static IEnumerable<OpenApiParameter> GetPathParametersForCurrentSegment(t
return Enumerable.Empty<OpenApiParameter>();
}
private const char PathNameSeparator = '\\';
[GeneratedRegex(@"-?id\d?}?$", RegexOptions.Singleline | RegexOptions.IgnoreCase, 100)]
[GeneratedRegex(@"-?id\d?}?$", RegexOptions.Singleline | RegexOptions.IgnoreCase, 200)]
private static partial Regex idClassNameCleanup();
///<summary>
/// Returns the class name for the node with more or less precision depending on the provided arguments
Expand Down Expand Up @@ -142,7 +142,7 @@ private static string GetSegmentName(this OpenApiUrlTreeNode currentNode, Struct
"yml",
"txt",
};
[GeneratedRegex(@"[\r\n\t]", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"[\r\n\t]", RegexOptions.Singleline, 200)]
private static partial Regex descriptionCleanupRegex();
public static string CleanupDescription(this string? description) => string.IsNullOrEmpty(description) ? string.Empty : descriptionCleanupRegex().Replace(description, string.Empty);
public static string GetPathItemDescription(this OpenApiUrlTreeNode currentNode, string label, string? defaultValue = default)
Expand Down Expand Up @@ -174,9 +174,9 @@ private static bool IsPathSegmentWithNumberOfParameters(this string currentSegme

return eval(currentSegment.Where(static x => x == RequestParametersChar));
}
[GeneratedRegex(@"\.(?:json|yaml|yml|csv|txt)$", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"\.(?:json|yaml|yml|csv|txt)$", RegexOptions.Singleline, 200)]
private static partial Regex stripExtensionForIndexersRegex(); // so {param-name}.json is considered as indexer
[GeneratedRegex(@"\{\w+\}\.(?:json|yaml|yml|csv|txt)$", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"\{\w+\}\.(?:json|yaml|yml|csv|txt)$", RegexOptions.Singleline, 200)]
private static partial Regex stripExtensionForIndexersTestRegex(); // so {param-name}.json is considered as indexer
public static bool IsComplexPathMultipleParameters(this OpenApiUrlTreeNode currentNode) =>
(currentNode?.Segment?.IsPathSegmentWithNumberOfParameters(static x => x.Any()) ?? false) && !currentNode.IsPathSegmentWithSingleSimpleParameter();
Expand Down Expand Up @@ -215,7 +215,7 @@ public static string GetUrlTemplate(this OpenApiUrlTreeNode currentNode)
SanitizePathParameterNamesForUrlTemplate(currentNode.Path.Replace('\\', '/'), pathReservedPathParametersIds) +
queryStringParameters;
}
[GeneratedRegex(@"{(?<paramname>[^}]+)}", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"{(?<paramname>[^}]+)}", RegexOptions.Singleline, 200)]
private static partial Regex pathParamMatcher();
private static string SanitizePathParameterNamesForUrlTemplate(string original, HashSet<string> reservedParameterNames)
{
Expand All @@ -236,7 +236,7 @@ public static string SanitizeParameterNameForUrlTemplate(this string original)
.Replace(".", "%2E", StringComparison.OrdinalIgnoreCase)
.Replace("~", "%7E", StringComparison.OrdinalIgnoreCase);// - . ~ are invalid uri template character but don't get encoded by Uri.EscapeDataString
}
[GeneratedRegex(@"%[0-9A-F]{2}", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"%[0-9A-F]{2}", RegexOptions.Singleline, 200)]
private static partial Regex removePctEncodedCharacters();
public static string SanitizeParameterNameForCodeSymbols(this string original, string replaceEncodedCharactersWith = "")
{
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static string ReplaceDotsWithSlashInNamespaces(this string? namespaced)
///<summary>
/// Cleanup regex that removes all special characters from ASCII 0-127
///</summary>
[GeneratedRegex(@"[""\s!#$%&'()*,./:;<=>?@\[\]\\^`’{}|~-](?<followingLetter>\w)?", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"[""\s!#$%&'()*,./:;<=>?@\[\]\\^`’{}|~-](?<followingLetter>\w)?", RegexOptions.Singleline, 200)]
private static partial Regex propertyCleanupRegex();
private const string CleanupGroupName = "followingLetter";
public static string CleanupSymbolName(this string? original)
Expand Down Expand Up @@ -181,7 +181,7 @@ public static string CleanupSymbolName(this string? original)

return result;
}
[GeneratedRegex(@"^(?<number>\d+)", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"^(?<number>\d+)", RegexOptions.Singleline, 200)]
private static partial Regex NumbersSpellingRegex();
private static readonly Dictionary<char, string> SpelledOutNumbers = new() {
{'0', "Zero"},
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Refiners/RubyRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ parameterType.TypeDefinition is CodeClass parameterTypeClass &&
}
CrawlTree(currentElement, x => UpdateReferencesToDisambiguatedClasses(x, classesToUpdate, suffix));
}
[GeneratedRegex(@"\\.(<letter>\\w)", RegexOptions.IgnoreCase | RegexOptions.Singleline, 100)]
[GeneratedRegex(@"\\.(<letter>\\w)", RegexOptions.IgnoreCase | RegexOptions.Singleline, 200)]
private static partial Regex CapitalizedFirstLetterAfterDot();
private static void FlattenModelsNamespaces(CodeElement currentElement, CodeNamespace modelsNS)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Kiota.Builder/Writers/CLI/CliCodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,10 @@ private static string NormalizeToOption(string input)
return result.ToLowerInvariant();
}

[GeneratedRegex("(?<=[a-z])[-_\\.]+([A-Za-z])", RegexOptions.Singleline, 100)]
[GeneratedRegex("(?<=[a-z])[-_\\.]+([A-Za-z])", RegexOptions.Singleline, 200)]
private static partial Regex DelimitedRegex();
[GeneratedRegex("(?<=[a-z])([A-Z])", RegexOptions.Singleline, 100)]
[GeneratedRegex("(?<=[a-z])([A-Z])", RegexOptions.Singleline, 200)]
private static partial Regex CamelCaseRegex();
[GeneratedRegex("([A-Z])", RegexOptions.Singleline, 100)]
[GeneratedRegex("([A-Z])", RegexOptions.Singleline, 200)]
private static partial Regex UppercaseRegex();
}
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void WriteFactoryMethodBody(CodeMethod codeElement, CodeClass parentClas
else
writer.WriteLine($"return new {parentClass.Name}();");
}
[GeneratedRegex(@"_(?<idx>\d+)", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"_(?<idx>\d+)", RegexOptions.Singleline, 200)]
private static partial Regex factoryMethodIndexParser();
private static void WriteFactoryOverloadMethod(CodeMethod codeElement, CodeClass parentClass, LanguageWriter writer)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/Java/JavaConventionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void WriteLongDescription(CodeElement element, LanguageWriter writer, IEn
writer.WriteLine(DocCommentEnd);
}
}
[GeneratedRegex(@"[^\u0000-\u007F]+", RegexOptions.None, 100)]
[GeneratedRegex(@"[^\u0000-\u007F]+", RegexOptions.None, 200)]
private static partial Regex nonAsciiReplaceRegex();
internal static string RemoveInvalidDescriptionCharacters(string originalDescription) =>
string.IsNullOrEmpty(originalDescription) ?
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/Php/CodeEnumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override void WriteCodeElement(CodeEnum codeElement, LanguageWriter write
writer.WriteLine($"public const {GetEnumValueName(enumProperty.Name)} = '{enumProperty.WireName}';");
}
}
[GeneratedRegex(@"([A-Z]{1})", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"([A-Z]{1})", RegexOptions.Singleline, 200)]
private static partial Regex _enumValueNameRegex();
private static string GetEnumValueName(string original)
{
Expand Down
4 changes: 2 additions & 2 deletions src/kiota/KiotaHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ private static Option<string> GetManifestOption(string defaultValue)
manifestOption.AddAlias("-a");
return manifestOption;
}
[GeneratedRegex(@"^[a-zA-Z_][\w_-]+", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"^[a-zA-Z_][\w_-]+", RegexOptions.Singleline, 200)]
private static partial Regex classNameRegex();
[GeneratedRegex(@"^[\w][\w\._-]+", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"^[\w][\w\._-]+", RegexOptions.Singleline, 200)]
private static partial Regex namespaceNameRegex();
private static Command GetGenerateCommand()
{
Expand Down
2 changes: 1 addition & 1 deletion src/kiota/Rpc/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static IEnumerable<string> GetOperationsFromTreeNode(OpenApiUrlTreeNode
Enumerable.Empty<string>())
.Union(node.Children.SelectMany(static x => GetOperationsFromTreeNode(x.Value)));
}
[GeneratedRegex(@"{\w+}", RegexOptions.Singleline, 100)]
[GeneratedRegex(@"{\w+}", RegexOptions.Singleline, 200)]
private static partial Regex indexingNormalizationRegex();
private static string NormalizeOperationNodePath(OpenApiUrlTreeNode node, OperationType operationType, bool forIndexing = false)
{
Expand Down

0 comments on commit 6ef5cec

Please sign in to comment.