Conversation
Add function to delete global application commands
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Co-authored-by: Nicky <111157596+xNickyDev@users.noreply.github.com>
Added $translateText and $chalkLog
| const FunctionCategoryRegex = /\r?\n(.*)(category: "\$?(\w+)"),?/m; | ||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim; | ||
| const OutputRegex = /output:(array(<[A-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((\w+|ArgType.(\w+)),?)+\]),/im; | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im; |
Check failure
Code scanning / CodeQL
Inefficient regular expression
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to rewrite the OutputRegex regular expression to eliminate ambiguity and nested quantifiers that can lead to exponential backtracking. Specifically:
- Replace ambiguous patterns like
\w+andarray(<[A-Za-z.]+>)?with more precise and non-overlapping patterns. - Use atomic grouping or possessive quantifiers where appropriate to prevent backtracking.
- Ensure the rewritten regular expression maintains the same functionality as the original.
The changes will be applied to the OutputRegex definition on line 13.
| @@ -12,3 +12,3 @@ | ||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim; | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im; | ||
| const OutputRegex = /output:(array(?:<[\w.]+>)?\([\w]*\)|\w+|ArgType\.\w+|\[(?:array(?:<[\w.]+>)?\([\w]*\)|\w+|ArgType\.\w+)(?:, (?:array(?:<[\w.]+>)?\([\w]*\)|\w+|ArgType\.\w+))*\]),/im; | ||
| function getOutputValues(fn, txt, enums) { |
| const FunctionCategoryRegex = /\r?\n(.*)(category: "\$?(\w+)"),?/m; | ||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim; | ||
| const OutputRegex = /output:(array(<[A-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((\w+|ArgType.(\w+)),?)+\]),/im; | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im; |
Check failure
Code scanning / CodeQL
Inefficient regular expression
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to rewrite the OutputRegex regular expression to eliminate ambiguities and nested quantifiers that can cause exponential backtracking. Specifically:
- Replace ambiguous patterns like
\w+andArgType\.\w+with more specific and non-overlapping patterns. - Use atomic grouping or possessive quantifiers (if supported) to prevent backtracking.
- Simplify the regex structure where possible to reduce complexity.
The updated regex will ensure that the matching process is linear in complexity, even for edge cases.
| @@ -12,3 +12,3 @@ | ||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim; | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im; | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType\.(\w+)|\[((?:array(?:<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+)(?:, ?))*\]),/im; | ||
| function getOutputValues(fn, txt, enums) { |
| @@ -12,10 +12,10 @@ | |||
| const FunctionNameRegex = /(name: "\$?(\w+)"),?/m | |||
| const FunctionCategoryRegex = /\r?\n(.*)(category: "\$?(\w+)"),?/m | |||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim | |||
| const OutputRegex = /output:(array(<[A-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((\w+|ArgType.(\w+)),?)+\]),/im | |||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im | |||
Check failure
Code scanning / CodeQL
Inefficient regular expression
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to rewrite the OutputRegex regular expression to eliminate ambiguity and reduce the potential for exponential backtracking. Specifically:
- Replace ambiguous sub-expressions like
\w+with more specific patterns that do not overlap with other alternatives. - Use atomic grouping (
(?>...)) or possessive quantifiers (if supported) to prevent backtracking where possible. - Simplify the regex by breaking it into smaller, more manageable parts if necessary.
The updated regex will ensure that the matching process is efficient and avoids exponential time complexity.
| @@ -14,3 +14,3 @@ | ||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType\.(\w+)|\[((?:array(?:<[A-Za-z.]+>)?\(\w*\)|ArgType\.\w+)(?:,(?:array(?:<[A-Za-z.]+>)?\(\w*\)|ArgType\.\w+))*)\]),/im | ||
|
|
| @@ -12,10 +12,10 @@ | |||
| const FunctionNameRegex = /(name: "\$?(\w+)"),?/m | |||
| const FunctionCategoryRegex = /\r?\n(.*)(category: "\$?(\w+)"),?/m | |||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim | |||
| const OutputRegex = /output:(array(<[A-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((\w+|ArgType.(\w+)),?)+\]),/im | |||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im | |||
Check failure
Code scanning / CodeQL
Inefficient regular expression
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to rewrite the OutputRegex regular expression to remove ambiguity and reduce the risk of catastrophic backtracking. Specifically:
- Replace ambiguous patterns like
\w+with more specific patterns that match the expected input. - Simplify nested alternations and repetitions to make the regex more efficient.
- Ensure that the regex still matches the intended patterns without introducing new bugs.
The updated regex will explicitly handle the expected cases without relying on overly broad patterns like \w+. This change will be made directly in the definition of OutputRegex on line 15.
| @@ -14,3 +14,3 @@ | ||
| const ArgEnumRegex = /(?:enum: +(\w+),?|Arg\.(?:\w+)Enum\([\r\n\t ]?(\w+))/gim | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|(\w+)|ArgType.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|\w+|ArgType\.\w+),?)+\]),/im | ||
| const OutputRegex = /output:(array(<[A-Za-z.]+>)?\((\w+)?\)|ArgType\.(\w+)|\[((array(<[A-Za-z.]+>)?\(\w*\)|ArgType\.\w+)(?:,\s*(array(<[A-Za-z.]+>)?\(\w*\)|ArgType\.\w+))*)\]),/im | ||
|
|
No description provided.