-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧪 Add Regexp.linear_time? tests; ✅ Update BEG_REGEXP to pass #145
Conversation
353a210
to
ae09bc5
Compare
The tests I've added collect every Regexp const and every Regexp literal that is inside method bodies, for all of @hsbt & @shugo: have you seen any tests like I've implemented here, elsewhere? It seems very useful for automatically detecting and preventing ReDoS vulnerabilities. Do you know any way to detect whether a constant has been deprecated? |
@hsbt & @shugo Also, what do you think about the changes to I have some other updates planned for our lexer, for both simplification and performance. But those will come later. 🙂 |
ae09bc5
to
b904e90
Compare
b904e90
to
85832e8
Compare
85832e8
to
b656450
Compare
`BEG_REGEXP` has been significantly changed to run in linear-time when running in ruby 3.2. All lookahead has been eliminated. A correct regexp for `ATOM` is implemented but unused. `ATOMISH` describes the current behavior, which ignores "[" chars. The `msg-att` field labels require the `ATOMISH` definition, for now... A regexp for `TAG` is implemented but also unused for now.
b656450
to
68fdef1
Compare
I've not seen that yet. We have an idea about it on rubocop rule when Ruby 3.2 released. /cc @makenowjust |
Yeah, another good approach would be to use parser to test all regexp literals. That should work well for rubocop, but it misses out on consts which are created with dynamically constructed regexps and dynamic method definitions created using Another check would be to look at local vars on method bindings. That would work, right? It should catch dynamic definitions such as: But a parser-based approach could test regexp literals that use simple regexp-escaped interpolation, like |
BEG_REGEXP
has been significantly changed to run in linear-time when running in ruby 3.2. All lookahead has been eliminated.A correct regexp for
ATOM
is implemented but unused.ATOMISH
describes the current behavior, which ignores "[" chars. Themsg-att
field labels require theATOMISH
definition, for now...A regexp for
TAG
is implemented but also unused for now.