Closed adfoster-r7 closed 1 year ago
Confirmed this works as expected:
~/git/metasploit-framework │ land-pr17291:pr/17291 ?17 rails console ✔ │ 4s │ 3.0.5 Ruby │ 06:07:45 PM
Loading development environment (Rails 7.0.4.1)
irb(main):001:0> [BinData::Int64le.new(123)].sum
DEPRECATION WARNING: Rails 7.0 has deprecated Enumerable.sum in favor of Ruby's native implementation available since 2.4. Sum of non-numeric elements requires an initial argument. (called from <top (required)> at (irb):1)
=> 123
irb(main):002:0> [BinData::Int64le.new(123)].sum(&:to_i)
=> 123
irb(main):003:0>
One thing to note with this new behavior is that nested array behavior appears to behave a little differently:
irb(main):008:0> [[3],[33]].sum
=> [3, 33]
irb(main):009:0> [[3],[33]].sum(&:to_i)
/home/gwillcox/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/activesupport-6.1.7/lib/active_support/core_ext/enumerable.rb:41:in `map': undefined method `to_i' for [3]:Array (NoMethodError)
Did you mean? to_s
to_a
to_h
irb(main):010:0>
Don't think it should be an issue here since we aren't using nested arrays but did want to call it out as a gotcha in terms of changed behavior to be aware of.
Fixes an issue when running Rails 7 and RubySMB - https://github.com/rapid7/metasploit-framework/pull/17291
When running Metasplotit's secrets dump module we get a deprecation warning from rails:
Tracked the warning down to:
https://github.com/rails/rails/commit/afa83350deef906ed01b7acb5da6e9285aab661f#diff-55ebe1b9975bc2c8530cd262bd89b31434a4a852f39d1e79a17dcf7f9f03b8ffR66-R68
Because BinData's integers don't pass the
first.is_a?(Numeric)
logic check Minimal example in Rails prompt:Whilst the following works in both Rails and Ruby