News for hackers. Stuff that matters.
Re:Rulex – A new, portable, regular expression language by kevincox on Friday June 10, 2022 @06:26AM (#31692165)
It is incredibly relevant if you want to process uset-provided expressions. Otherwise you expose yourself to a DoS attack.

The Rust regex crate is also DFA based and safe for untrusted inputs.

Re:Rulex – A new, portable, regular expression language by Someone on Friday June 10, 2022 @06:31AM (#31692204)
.NET added timeouts to handle that. It’s a per-regex setting with a global default (https://docs.microsoft.com/en-us/dotnet/api/system.text.regu...).
Re:Rulex – A new, portable, regular expression language by nsajko on Friday June 10, 2022 @06:45AM (#31692280)
I guess that adding timeouts can significantly decrease the run time efficiency?
Re:Rulex – A new, portable, regular expression language by Someone on Friday June 10, 2022 @07:10AM (#31692442)
It can, but this isn’t a hard timeout. From the description (“The MatchTimeout property defines the approximate maximum time interval for a Regex instance to execute”), it seems they have their regex engine periodically (say after handling every 10,000 instructions of the compiled regex) check whether they went over the limit.
Re:Rulex – A new, portable, regular expression language by orra on Friday June 10, 2022 @07:44AM (#31692707)
Plus, as a general point, .NET has pretty decent performance. It's no C++, but at the same time substantial effort is put into optimisation.

In fact for both .NET v5 and v7, they specifically did work to improve the performance of regexes. For example there is a new non-backtracking option. https://devblogs.microsoft.com/dotnet/regular-expression-imp...

Re:Rulex – A new, portable, regular expression language by SonOfLilit on Friday June 10, 2022 @06:30AM (#31692194)
Nice to know about Rust. From reading the docs the situation seems to be more complicated and more impressive: https://docs.rs/regex/latest/regex/#untrusted-input
Re:Rulex – A new, portable, regular expression language by masklinn on Friday June 10, 2022 @07:10AM (#31692445)
There’s also the postgres regex engine, I don’t know how it works under the hood but it’s very resistant to catastrophic backtracking despite features which normally translate to nfa (e.g. backrefs).
Re:Rulex – A new, portable, regular expression language by nsajko on Friday June 10, 2022 @07:14AM (#31692475)
> features which normally translate to nfa (e.g. backrefs)

You're very wrong, backreferences in general can't be translated to finite automata (NFA is short for nondeterministic finite automaton). See these comments:

https://news.ycombinator.com/item?id=18431610

https://news.ycombinator.com/item?id=27877743

Re:Rulex – A new, portable, regular expression language by masklinn on Friday June 10, 2022 @11:34AM (#31695596)
Maybe try to read my comment again because I don't think you understood what I wrote.
Re:Rulex – A new, portable, regular expression language by nsajko on Friday June 10, 2022 @04:04PM (#31698798)
You say:

> resistant to catastrophic backtracking despite features which normally translate to nfa

I interpret this as you equating NFA with backtracking engines, which would be incorrect. Is my interpretation wrong?