lib/mihari/analyzers/censys.rb in mihari-4.3.0 vs lib/mihari/analyzers/censys.rb in mihari-4.4.0

- old
+ new

@@ -7,14 +7,31 @@ class Censys < Base param :query option :interval, default: proc { 0 } + # @return [String, nil] + attr_reader :id + + # @return [String, nil] + attr_reader :secret + + def initialize(*args, **kwargs) + super(*args, **kwargs) + + @id = kwargs[:id] || Mihari.config.censys_id + @secret = kwargs[:secret] || Mihari.config.censys_secret + end + def artifacts search end + def configured? + configuration_keys.all? { |key| Mihari.config.send(key) } || (id? && secret?) + end + private # # Search # @@ -83,10 +100,18 @@ def configuration_keys %w[censys_id censys_secret] end def api - @api ||= ::Censys::API.new(Mihari.config.censys_id, Mihari.config.censys_secret) + @api ||= ::Censys::API.new(id, secret) + end + + def id? + !id.nil? + end + + def secret? + !secret.nil? end end end end