Skip to content

Potential fix for code scanning alert no. 2: Inefficient regular expression - #328

Closed
vermorag wants to merge 1 commit into
mainfrom
alert-autofix-2
Closed

vermorag wants to merge 1 commit into
mainfrom
alert-autofix-2

Conversation

@vermorag

Copy link
Copy Markdown
Member

Potential fix for https://github.com/cattr-app/server-application/security/code-scanning/2

The best fix is to replace the vulnerable regex with a linear-time, non-ambiguous email check that avoids nested ambiguous quantifiers.
In this file, update the regex in getModalInvite() (around line 292) to a safer pattern such as:

  • local part: [A-Za-z0-9._%+-]+
  • @
  • domain labels: [A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+

This removes the problematic (\.-?\w+)*-style ambiguity while preserving intended behavior (basic email format validation for invites).

Also switch from regex.exec(email) == null to !regex.test(email) for simple boolean validation (same functional intent, clearer usage).

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

… expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Alex <inbox@alexv-pro.ru>
@cattr-cla

cattr-cla Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Contributor License Agreement

✅ Every human contributor has accepted Cattr CLA version 1.

Exempt automation:

  • 🤖 github-advanced-security[bot]

CLA SHA-256: 68cb254dc87c899f320d5a8977e7e380fd8f6cf6f9388e51d07d936f3a8ce38b

@vermorag vermorag linked an issue Sep 19, 2026 that may be closed by this pull request
2 tasks
@vermorag vermorag self-assigned this Sep 19, 2026
@vermorag vermorag added the duplicate This issue or pull request already exists label Sep 19, 2026
@vermorag

Copy link
Copy Markdown
Member Author

Duplicate of #327

@vermorag vermorag marked this as a duplicate of #327 Sep 19, 2026
@vermorag vermorag closed this Sep 19, 2026
@vermorag
vermorag deleted the alert-autofix-2 branch September 19, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Development

Successfully merging this pull request may close these issues.

Fix code scanning alert - Inefficient regular expression

1 participant