lib/ukemi/services/virustotal.rb in ukemi-0.4.0 vs lib/ukemi/services/virustotal.rb in ukemi-0.4.1

- old
+ new

@@ -7,11 +7,11 @@ module Services class VirusTotal < Service private def config_keys - %w(VIRUSTOTAL_API_KEY) + %w[VIRUSTOTAL_API_KEY] end def api @api ||= ::VirusTotal::API.new end @@ -27,21 +27,21 @@ attributes = extract_attributes(res) convert_to_records attributes, "ip_address" end def extract_attributes(response) - data = response.dig("data") || [] + data = response["data"] || [] data.map do |item| - item.dig("attributes") || [] + item["attributes"] || [] end end def convert_to_records(attributes, key = nil) memo = Hash.new { |h, k| h[k] = [] } attributes.each do |attribute| - data = attribute.dig(key) - date = Time.at(attribute.dig("date")).to_date.to_s + data = attribute[key] + date = Time.at(attribute["date"]).to_date.to_s memo[data] << date end memo.keys.map do |data| Record.new(