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. 28: Inefficient regular expression #2262

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

kdinev
Copy link
Member

@kdinev kdinev commented Nov 4, 2024

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

To fix the problem, we need to modify the regular expression to remove the ambiguity that leads to exponential backtracking. Specifically, we should avoid using nested quantifiers that can match empty strings. In this case, we can refactor the regular expression to ensure that each part of the pattern is unambiguous and does not lead to excessive backtracking.

The best way to fix this issue is to replace the problematic part of the regular expression [\w\$]* with a more specific pattern that does not allow for empty matches. We can use a non-empty character class that matches one or more word characters or dollar signs, ensuring that the pattern is unambiguous.

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

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

coveralls commented Nov 5, 2024

Coverage Status

coverage: 84.633%. remained the same
when pulling 39bbb8e on alert-autofix-28
into cd46d63 on master.

@kdinev kdinev marked this pull request as ready for review November 5, 2024 09:45
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ChronosSF ChronosSF merged commit 63c065b into master Nov 5, 2024
4 checks passed
@ChronosSF ChronosSF deleted the alert-autofix-28 branch November 5, 2024 14:03
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.

3 participants