Class: Mihari::Enrichers::Whois

Inherits:
Base
  • Object
show all
Defined in:
lib/mihari/enrichers/whois.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited

Methods included from Mixins::Configurable

#configuration_keys, #configuration_values, #configured?

Class Method Details

.query(domain) ⇒ Mihari::WhoisRecord?

Query IAIA Whois API

Parameters:

  • name (String)

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mihari/enrichers/whois.rb', line 23

def query(domain)
  domain = PublicSuffix.domain(domain)

  # check memo
  if @memo.key?(domain)
    whois_record = @memo[domain]
    # return clone of the record
    return whois_record.dup
  end

  record = ::Whois.whois(domain)
  parser = record.parser

  return nil if parser.available?

  whois_record = WhoisRecord.new(
    domain: domain,
    created_on: get_created_on(parser),
    updated_on: get_updated_on(parser),
    expires_on: get_expires_on(parser),
    registrar: get_registrar(parser),
    contacts: get_contacts(parser)
  )
  # set memo
  @memo[domain] = whois_record
  whois_record
rescue ::Whois::Error, ::Whois::ParserError, Timeout::Error
  nil
end

.reset_cacheObject



53
54
55
# File 'lib/mihari/enrichers/whois.rb', line 53

def reset_cache
  @memo = {}
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/mihari/enrichers/whois.rb', line 11

def valid?
  true
end