lib/mihari/analyzers/shodan.rb in mihari-4.3.0 vs lib/mihari/analyzers/shodan.rb in mihari-4.4.0
- old
+ new
@@ -7,10 +7,19 @@
class Shodan < Base
param :query
option :interval, default: proc { 0 }
+ # @return [String, nil]
+ attr_reader :api_key
+
+ def initialize(*args, **kwargs)
+ super(*args, **kwargs)
+
+ @api_key = kwargs[:api_key] || Mihari.config.shodan_api_key
+ end
+
def artifacts
results = search
return [] unless results || results.empty?
results = results.map { |result| Structs::Shodan::Result.from_dynamic!(result) }
@@ -27,10 +36,10 @@
def configuration_keys
%w[shodan_api_key]
end
def api
- @api ||= ::Shodan::API.new(key: Mihari.config.shodan_api_key)
+ @api ||= ::Shodan::API.new(key: api_key)
end
#
# Search with pagination
#