Skip to content

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Jan 2, 2024

This PR adds a new eslint rule that flags the usage of new RegExp() constructor calls. The purpose of this rule is to make us aware of the potential danger of creating a regular expression from (end) user input. This has led to security incidents in the past.

To be clear, it is perfectly okay to ignore this rule in cases where we're sure that there's no danger or where input is already escaped.

We have other rules (+CodeQL) in place to avoid RegExp usage with static expressions but these didn't cover regular expressions where the expression itself or the flags were constructed from variables.

closes #9960

@Lms24 Lms24 requested review from anonrig, lforst and mydea January 2, 2024 13:08
@Lms24 Lms24 marked this pull request as ready for review January 2, 2024 13:08
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one!

@Lms24 Lms24 merged commit bf9f2e6 into develop Jan 2, 2024
@Lms24 Lms24 deleted the lms/chore-eslint-avoid-regexp-ctor branch January 2, 2024 14:51
anonrig pushed a commit that referenced this pull request Jan 3, 2024
Add a new eslint rule that flags the usage of `new RegExp()`
constructor calls. The purpose of this rule is to make us aware of the
potential danger of creating a regular expression from (end) user input.
This has led to security incidents in the past.

To be clear, it is perfectly okay to ignore this rule in cases where
we're sure that there's no danger or where input is already escaped.
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.

Add Lint rule to flag RegExp usage

4 participants