Class: X509Sleuth::Scanner::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/x509_sleuth/scanner/target.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Target

Returns a new instance of Target.



8
9
10
# File 'lib/x509_sleuth/scanner/target.rb', line 8

def initialize(target)
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



6
7
8
# File 'lib/x509_sleuth/scanner/target.rb', line 6

def target
  @target
end

Instance Method Details

#hostsObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/x509_sleuth/scanner/target.rb', line 18

def hosts
  @hosts ||=
    if is_a_range?
      cidr = NetAddr::CIDR.create(target)
      cidr.enumerate.reject do |address|
        [cidr.network, cidr.broadcast].include?(address)
      end
    else
      [target]
    end
end

#is_a_range?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/x509_sleuth/scanner/target.rb', line 12

def is_a_range?
  NetAddr::CIDR.create(target).size > 1 ? true : false 
rescue NetAddr::ValidationError
  false
end