ReDoS: add a shared regex pack #11061
Open
+3,290
−0
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.
This PR introduces a new shared
regexpack containing various shared code that analyze regular expressions.All these analyses depend on a single
RegexTreeViewSigsignature, that describes a regex as a tree structure.I don't expect that a shared regex parser will ever make it into this pack.
This is just the shared pack, there are separate PRs that will integrate this shared pack with each language (see bottom).
A complete PR, that combines all the part, can be found here: #10604 (ugly commit history).
I ended up basing locations on
hasLocationInfoas not all languages hadLocationobjects for all the regex terms.This also required some small rewrites in the implementation.
The class hierarchy inside
RegexTreeViewSigwas needed in order to have some hierarchy that all the languages could agree on, and that's why I had to introduce aTopclass.(
RegExpParenthas a slightly different hierarchy in JS).This PR should only be merged when a stable CLI supports all the required features, and when all the major core bugs have been fixed.
I've made separate PRs that port each language to the shared pack:
JavaScript, Ruby, Python, Java.
TODO:
${workspace}for intra-workspace dependencies #11004