From bcfe434d1ec880ef727b5406b44c3470cd3523b6 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Wed, 12 Dec 2018 11:47:14 -0600 Subject: [PATCH] Update to_ar to use symbolized keys --- .../data_service/remote/http/response_data_helper.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/metasploit/framework/data_service/remote/http/response_data_helper.rb b/lib/metasploit/framework/data_service/remote/http/response_data_helper.rb index ec170fc61a..8739dfbb7b 100644 --- a/lib/metasploit/framework/data_service/remote/http/response_data_helper.rb +++ b/lib/metasploit/framework/data_service/remote/http/response_data_helper.rb @@ -49,7 +49,7 @@ module ResponseDataHelper begin body = process_response(response_wrapper) if !body.nil? && !body.empty? - parsed_body = JSON.parse(body).symbolize_keys + parsed_body = JSON.parse(body, symbolize_names: true) data = Array.wrap(parsed_body[:data]) rv = [] data.each do |json_object| @@ -107,7 +107,9 @@ module ResponseDataHelper reflection end - data.except(*obj.attributes.keys).each do |k, v| + obj_attribute_names = obj.attributes.transform_keys { |k| k.to_sym }.keys + + data.except(*obj_attribute_names).each do |k, v| association = klass.reflect_on_association(k) next unless association @@ -133,7 +135,7 @@ module ResponseDataHelper end end end - obj.assign_attributes(data.slice(*obj.attributes.keys)) + obj.assign_attributes(data.slice(*obj_attribute_names)) obj.instance_eval do # prevent save