Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
9d0029e to
9f4ef40
Compare
3f1515b to
609f1a5
Compare
examples/metamask/test/config.ts
Outdated
| @@ -0,0 +1,5 @@ | |||
| export default { | |||
| baseUrl: 'https://www.alphabot.app/', | |||
There was a problem hiding this comment.
the page user added as an example - this test case is more for you as a prove that this issue has been fixed
| @@ -0,0 +1,12 @@ | |||
| export function extractWalletSetupFunction(sourceCode: string): string { | |||
| const match = sourceCode.match( | |||
| /defineWalletSetup\s*\([^,]*,\s*(async\s*\([^)]*\)\s*=>\s*{(?:[^{}]*|{(?:[^{}]*|{[^{}]*})*})*})\s*\)/ | |||
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to modify the regular expression to remove the ambiguity and reduce the potential for excessive backtracking. This can be achieved by making the sub-expressions more specific and avoiding patterns that can match the same string in multiple ways. Specifically, we can replace [^{}]* with a more precise pattern that matches the intended input without allowing for excessive backtracking.
The best way to fix the problem is to rewrite the regular expression to avoid ambiguous sub-expressions and nested quantifiers. We can achieve this by using non-capturing groups and more specific character classes.
| @@ -2,3 +2,3 @@ | ||
| const match = sourceCode.match( | ||
| /defineWalletSetup\s*\([^,]*,\s*(async\s*\([^)]*\)\s*=>\s*{(?:[^{}]*|{(?:[^{}]*|{[^{}]*})*})*})\s*\)/ | ||
| /defineWalletSetup\s*\([^,]*,\s*(async\s*\([^)]*\)\s*=>\s*{(?:[^{}{}]*|{(?:[^{}{}]*|{[^{}{}]*})*})*})\s*\)/ | ||
| ) |
| @@ -0,0 +1,12 @@ | |||
| export function extractWalletSetupFunction(sourceCode: string): string { | |||
| const match = sourceCode.match( | |||
| /defineWalletSetup\s*\([^,]*,\s*(async\s*\([^)]*\)\s*=>\s*{(?:[^{}]*|{(?:[^{}]*|{[^{}]*})*})*})\s*\)/ | |||
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that leads to catastrophic backtracking. This can be achieved by making the pattern more specific and less ambiguous. In this case, we can replace the ambiguous [^{}]* with a more precise pattern that matches the expected structure of the input.
The best way to fix the problem without changing existing functionality is to rewrite the regular expression to avoid nested quantifiers and ambiguous patterns. Specifically, we can use a non-recursive approach to match the nested braces and their contents.
| @@ -2,3 +2,3 @@ | ||
| const match = sourceCode.match( | ||
| /defineWalletSetup\s*\([^,]*,\s*(async\s*\([^)]*\)\s*=>\s*{(?:[^{}]*|{(?:[^{}]*|{[^{}]*})*})*})\s*\)/ | ||
| /defineWalletSetup\s*\([^,]*,\s*(async\s*\([^)]*\)\s*=>\s*{[^{}]*(?:{[^{}]*}[^{}]*)*})\s*\)/ | ||
| ) |
No description provided.