Skip to content

Fix code scanning alert no. 1: Regular expression injection#20

Draft
litencatt wants to merge 1 commit intomainfrom
alert-autofix-1
Draft

Fix code scanning alert no. 1: Regular expression injection#20
litencatt wants to merge 1 commit intomainfrom
alert-autofix-1

Conversation

@litencatt
Copy link
Copy Markdown
Owner

Fixes https://github.com/litencatt/gallery-fake/security/code-scanning/1

To fix the problem, we need to sanitize the ws variable before using it to construct the regular expression. We can use the _.escapeRegExp function from the lodash library to escape any special characters in the ws variable. This will ensure that the regular expression is constructed safely without any risk of injection.

  1. Install the lodash library if it is not already installed.
  2. Import the _.escapeRegExp function from lodash.
  3. Use _.escapeRegExp to sanitize the ws variable before using it in the regular expression.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.

1 participant