Uh oh!
There was an error while loading. Please reload this page.
🧪 Add Regexp.linear_time? tests; ✅ Update BEG_REGEXP to pass - #145
Conversation
nevans
commented
Apr 16, 2023
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? |
nevans
commented
Apr 16, 2023
@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. 🙂 |
`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.
hsbt
commented
Apr 18, 2023
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_REGEXPhas been significantly changed to run in linear-time when running in ruby 3.2. All lookahead has been eliminated.A correct regexp for
ATOMis implemented but unused.ATOMISHdescribes the current behavior, which ignores "[" chars. Themsg-attfield labels require theATOMISHdefinition, for now...A regexp for
TAGis implemented but also unused for now.