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. 1: Regular expression injection #6

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

aszeszo
Copy link
Collaborator

@aszeszo aszeszo commented Oct 4, 2024

Fixes https://github.com/sede-open/github-tag-action/security/code-scanning/1

To fix the problem, we need to sanitize the tagPrefix input before using it in the regular expression. The best way to do this is by using a sanitization function such as _.escapeRegExp from the lodash library. This function escapes special characters in the input that have special meaning in regular expressions, thus preventing injection attacks.

  • Add the lodash library to the project if it is not already included.
  • Import the _.escapeRegExp function from lodash.
  • Use _.escapeRegExp to sanitize the tagPrefix input before constructing 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>
@aszeszo aszeszo marked this pull request as ready for review October 4, 2024 14:33
@aszeszo aszeszo merged commit 97a8854 into master Oct 4, 2024
4 of 7 checks passed
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