Skip to content

Limit Date.parse input length and make interruptible#6952

Merged
enebo merged 5 commits intojruby:jruby-9.3from
headius:date_parse_limit93
Nov 30, 2021
Merged

Limit Date.parse input length and make interruptible#6952
enebo merged 5 commits intojruby:jruby-9.3from
headius:date_parse_limit93

Conversation

@headius
Copy link
Member

@headius headius commented Nov 30, 2021

Excessively long input to the various Date parsing methods can cause the calling thread to run for a long time, perhaps tying it up indefinitely. This PR incorporates to changes similar to those in ruby/date@3959acc.

  • Add a limit option to the affected Date parse methods (see commit above for the list).
  • Make all regexp matches interruptible by default. This can be disabled using the JRuby property regexp.interruptible=false in .jruby_opts, with -Xregexp.interruptible=false on the command line, or by setting the JVM property jruby.regexp.interruptible=false
  • Add the same test as CRuby under our JRuby test suite, since no spec was added by ruby-core and we are not merging updated tests for this release.

This patch differs from #6951 in that it enables interruptible Regexp matches globally, since this appears to now be the case in CRuby. This also simplifies the PR and avoids modifying the Java code.

The pure-Ruby workaround from #6951 applies here, and manually enabling the regexp.interruptible property would bring a patched 9.3.1 or 9.3.0 install up to compliance with the test added here. No rebuild of JRuby is needed in this case.

cc @jordansissel, @rsim

@headius headius added this to the JRuby 9.3.2.0 milestone Nov 30, 2021
@headius headius changed the title Date parse limit93 Limit Date.parse input length and make interruptible Nov 30, 2021
This test passes to DateTime.parse a keyword argument
"create_additions" that is unknown to DateTime, but because CRuby
only checks for the "limit" option it expects, this does not cause
any error. In JRuby, where we still have this code in Ruby, the
unknown keyword is explicitly rejected. We exclude this for now
and will fix the bad test in json lib.
@enebo enebo merged commit 0868c69 into jruby:jruby-9.3 Nov 30, 2021
@headius headius deleted the date_parse_limit93 branch December 1, 2021 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants