Fix RegEx queries in PostgreSQL Repository #8489
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the search mechanism in the PostgreSQL Repository connector to remove the "\Q...\E" delimitors used to ensure any string from an outside caller can not be executed as a RegEx as part of a query. The delimitors cause the RegEx engine to ignore the text between.
The reason for removing these delimiters is that they are not truely part of the RegEx spec (they come from Purl) and PostgreSQL does not support them. When they are removed, the searches find what is expected.
The reason for using these delimitors is to prevent a denial of service attack that uses bad RegEx to cause big workloads on the database. In order to compensate for removing this protectuon. each RegEx is tested, and if it takes too long to execute, the easrch request is rejected with a RepositoryErrorException.
Related Issue(s)
None
Testing
Testing using a variety of queries
Release Notes & Documentation
None - this is a bug fix
Additional notes
None