2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
require 'json'
|
|
|
|
|
|
|
|
describe "String#to_f" do
|
2017-05-07 08:05:36 -04:00
|
|
|
|
2017-05-07 08:04:49 -04:00
|
|
|
it "resists CVE-2013-4164 by converting very long Strings to a Float" do
|
|
|
|
"1.#{'1'*1000000}".to_f.should be_close(1.1111111111111112, TOLERANCE)
|
|
|
|
end
|
2017-05-07 08:05:36 -04:00
|
|
|
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "JSON.parse" do
|
2017-05-07 08:05:36 -04:00
|
|
|
|
2017-05-07 08:04:49 -04:00
|
|
|
it "resists CVE-2013-4164 by converting very long Strings to a Float" do
|
|
|
|
JSON.parse("[1.#{'1'*1000000}]").first.should be_close(1.1111111111111112, TOLERANCE)
|
|
|
|
end
|
2017-05-07 08:05:36 -04:00
|
|
|
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|