Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

fix: LEAP-509: Optimize regular expression for improved performance #1673

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

juliosgarbi
Copy link
Contributor

This PR addresses inefficient regular expressions in the code, as identified by GitHub's code scan. In particular, the regular expression "(?""|[^""]+)*" has been causing performance issues and potential security risks. The goal is to enhance performance and mitigate the risk of Denial of Service ("DoS") attacks. https://github.com/HumanSignal/label-studio/security/code-scanning/760

PR fulfills these requirements

  • Commit message(s) and PR title follows the format [fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made ex. fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
  • Tests for the changes have been added/updated (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.)
  • Self-reviewed and ran all changes on a local instance (for bug fixes/features)

Change has impacts in these area(s)

  • Product design
  • Backend (Database)
  • Backend (API)
  • Frontend

What does this fix?

By optimizing the regular expression, this change improves code performance and reduces the risk of DoS attacks. It ensures that the regular expression matching process is more efficient and not negatively affecting the application's responsiveness.

Does this change affect performance?

Yes, this change positively affects performance. The replacement of the inefficient regular expression with the optimized regex "(?:""|[^"])*" significantly improves matching efficiency. It reduces the risk of performance issues, making the regular expression matching process more efficient and responsive.

@juliosgarbi
Copy link
Contributor Author

juliosgarbi commented Jan 24, 2024

/git merge master

Workflow run
Successfully pushed new changes:
Merge remote-tracking branch 'origin/master' into fb-leap-509 (62340c4)

@juliosgarbi juliosgarbi merged commit 4e777d3 into master Jan 24, 2024
13 of 14 checks passed
@juliosgarbi juliosgarbi deleted the fb-leap-509 branch January 24, 2024 20:46
MasherJames pushed a commit to HelloPareto/label-studio-frontend that referenced this pull request Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants