Skip to content

Commit

Permalink
Merge pull request #5 from ninoseki/fix-st-issue
Browse files Browse the repository at this point in the history
fix: fix ST issue
  • Loading branch information
ninoseki committed Mar 16, 2020
2 parents 0ac8d94 + a8da3e8 commit ff4d588
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lib/ukemi/services/securitytrails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ def lookup_by_ip(data)
def lookup_by_domain(data)
result = api.history.get_all_dns_history(data, type: "a")
records = result.dig("records") || []
records.map do |record|

memo = Hash.new { |h, k| h[k] = [] }
records.each do |record|
values = record.dig("values") || []
values.map do |value|
Record.new(
data: value.dig("ip"),
first_seen: record.dig("first_seen"),
last_seen: record.dig("last_seen"),
source: name
)
values.each do |value|
ip = value.dig("ip")
memo[ip] << record.dig("first_seen")
memo[ip] << record.dig("last_seen")
end
end.flatten
end
end

def extract_attributes(response)
data = response.dig("data") || []
data.map do |item|
item.dig("attributes") || []
memo.keys.map do |ip|
Record.new(
data: ip,
first_seen: memo[ip].min,
last_seen: memo[ip].max,
source: name
)
end
end
end
Expand Down

0 comments on commit ff4d588

Please sign in to comment.