lib/mihari/analyzers/shodan.rb in mihari-0.9.0 vs lib/mihari/analyzers/shodan.rb in mihari-0.9.1

- old
+ new

@@ -3,20 +3,18 @@ require "shodan" module Mihari module Analyzers class Shodan < Base - attr_reader :api attr_reader :title attr_reader :description attr_reader :query attr_reader :tags def initialize(query, title: nil, description: nil, tags: []) super() - @api = ::Shodan::API.new @query = query @title = title || "Shodan lookup" @description = description || "query = #{query}" @tags = tags end @@ -30,9 +28,13 @@ match.dig "ip_str" end.compact end private + + def api + @api ||= ::Shodan::API.new + end def search api.host.search(query) rescue ::Shodan::Error => _e nil