Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 27: Inefficient regular expression #2263

Closed
wants to merge 11 commits into from

Conversation

kdinev
Copy link
Member

@kdinev kdinev commented Nov 4, 2024

Fixes https://github.com/IgniteUI/ignite-ui/security/code-scanning/27

To fix the problem, we need to modify the regular expression to remove the ambiguity that causes exponential backtracking. Specifically, we can replace the ambiguous character class [\w\$\-]+ with a more precise pattern that avoids backtracking issues. One approach is to use a non-capturing group with a negated character class to ensure that the pattern matches in a linear time complexity.

  • General Fix: Modify the regular expression to use a non-capturing group with a negated character class to avoid backtracking.
  • Detailed Fix: Replace the pattern [\w\$\-]+ with (?:[^\s{}])+ to match one or more characters that are not whitespace, curly braces, or other problematic characters.
  • File/Region/Lines to Change: The change should be made in the file src/js/modules/infragistics.templating.js on line 129.
  • Required Changes: No additional methods, imports, or definitions are needed to implement this change.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

kdinev and others added 2 commits November 4, 2024 16:23
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
kdinev and others added 2 commits November 5, 2024 16:06
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@coveralls
Copy link

Coverage Status

coverage: 84.637%. remained the same
when pulling c7b8043 on alert-autofix-27
into 63c065b on master.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
kdinev and others added 5 commits November 5, 2024 16:47
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@kdinev kdinev closed this Nov 12, 2024
@kdinev kdinev deleted the alert-autofix-27 branch November 12, 2024 09:49
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.

2 participants