Skip to content

v2.3.0#371

Merged
xNickyDev merged 49 commits into
mainfrom
dev
Apr 28, 2025
Merged

v2.3.0#371
xNickyDev merged 49 commits into
mainfrom
dev

Conversation

@xNickyDev

Copy link
Copy Markdown
Member

No description provided.

xNickyDev and others added 30 commits February 14, 2025 23:02
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>
Project Econome and others added 18 commits April 7, 2025 19:55
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
Comment thread dist/functions/generateMetadata.js Fixed
Comment thread dist/functions/generateMetadata.js Fixed
Comment thread dist/functions/generateMetadata.js Fixed
Comment thread dist/functions/generateMetadata.js Fixed
Comment thread src/functions/generateMetadata.ts Fixed
Comment thread src/functions/generateMetadata.ts Fixed
Comment thread src/functions/generateMetadata.ts Fixed
Comment thread src/functions/generateMetadata.ts Fixed
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

This part of the regular expression may cause exponential backtracking on strings starting with 'output:\[' and containing many repetitions of 'a'.

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:

  1. Replace ambiguous patterns like \w+ and array(<[A-Za-z.]+>)? with more precise and non-overlapping patterns.
  2. Use atomic grouping or possessive quantifiers where appropriate to prevent backtracking.
  3. Ensure the rewritten regular expression maintains the same functionality as the original.

The changes will be applied to the OutputRegex definition on line 13.


Suggested changeset 1
dist/functions/generateMetadata.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/dist/functions/generateMetadata.js b/dist/functions/generateMetadata.js
--- a/dist/functions/generateMetadata.js
+++ b/dist/functions/generateMetadata.js
@@ -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) {
EOF
@@ -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) {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
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

This part of the regular expression may cause exponential backtracking on strings starting with 'output:\[argtype.' and containing many repetitions of 'aaargtype.'.

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:

  1. Replace ambiguous patterns like \w+ and ArgType\.\w+ with more specific and non-overlapping patterns.
  2. Use atomic grouping or possessive quantifiers (if supported) to prevent backtracking.
  3. 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.


Suggested changeset 1
dist/functions/generateMetadata.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/dist/functions/generateMetadata.js b/dist/functions/generateMetadata.js
--- a/dist/functions/generateMetadata.js
+++ b/dist/functions/generateMetadata.js
@@ -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) {
EOF
@@ -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) {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@@ -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

This part of the regular expression may cause exponential backtracking on strings starting with 'output:\[' and containing many repetitions of 'a'.

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:

  1. Replace ambiguous sub-expressions like \w+ with more specific patterns that do not overlap with other alternatives.
  2. Use atomic grouping ((?>...)) or possessive quantifiers (if supported) to prevent backtracking where possible.
  3. 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.


Suggested changeset 1
src/functions/generateMetadata.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/functions/generateMetadata.ts b/src/functions/generateMetadata.ts
--- a/src/functions/generateMetadata.ts
+++ b/src/functions/generateMetadata.ts
@@ -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
 
EOF
@@ -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

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@@ -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

This part of the regular expression may cause exponential backtracking on strings starting with 'output:\[argtype.' and containing many repetitions of 'aaargtype.'.

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:

  1. Replace ambiguous patterns like \w+ with more specific patterns that match the expected input.
  2. Simplify nested alternations and repetitions to make the regex more efficient.
  3. 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.


Suggested changeset 1
src/functions/generateMetadata.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/functions/generateMetadata.ts b/src/functions/generateMetadata.ts
--- a/src/functions/generateMetadata.ts
+++ b/src/functions/generateMetadata.ts
@@ -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
 
EOF
@@ -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

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@xNickyDev
xNickyDev merged commit 9bbdf13 into main Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants