Skip to content

Use com.google.re2j.Pattern for regex matching#116

Merged
etiennehomer merged 1 commit intomainfrom
test_sonar
Jul 17, 2025
Merged

Use com.google.re2j.Pattern for regex matching#116
etiennehomer merged 1 commit intomainfrom
test_sonar

Conversation

@etiennehomer
Copy link
Collaborator

@etiennehomer etiennehomer commented Jul 17, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines

Does this PR already have an issue describing the problem?
Sonar security issue: "Change this code to not construct the regular expression from user-controlled data."
https://sonarcloud.io/project/issues?impactSoftwareQualities=SECURITY&issueStatuses=OPEN%2CCONFIRMED&id=com.powsybl%3Apowsybl-case-server&open=AZeCKPshG0-VpRsyXwuX

What kind of change does this PR introduce?
Fix high level security issue.

What is the current behavior?
A regex can be given through the endpoint and executed by java.util.regex.Pattern. This can lead to backtracking issues.

What is the new behavior (if this is a feature change)?
We now use com.google.re2j.Pattern to execute the regex. This lib prevents from regular expression denial of service. See powsybl/powsybl-core@72f79de

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
@etiennehomer etiennehomer changed the title com.google.re2j.Pattern Use com.google.re2j.Pattern for regex matching Jul 17, 2025
@sonarqubecloud
Copy link

Copy link
Collaborator

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

Consistent with powsybl implementation powsybl/powsybl-core@72f79de

@etiennehomer etiennehomer merged commit d45d6c1 into main Jul 17, 2025
6 checks passed
@etiennehomer etiennehomer deleted the test_sonar branch July 17, 2025 14:36
dbraquart pushed a commit that referenced this pull request Jul 18, 2025
Signed-off-by: Etienne Homer <etiennehomer@gmail.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.

2 participants