class SslscanWrapper::Report

Attributes

body[R]

The content body of the report

doc[R]

The nokogiri document object

Public Class Methods

all_attr_values_accessor(name, xpath) click to toggle source
# File lib/sslscan_wrapper/report.rb, line 52
def self.all_attr_values_accessor(name, xpath)
  define_method(name) do
    @doc.xpath(xpath).map(&:value)
  end
end
attr_first_value_accessor(name, xpath) click to toggle source
# File lib/sslscan_wrapper/report.rb, line 24
def self.attr_first_value_accessor(name, xpath)
  define_method(name) do
    node = @doc.xpath(xpath).first
    node.value unless node.nil?
  end
end
attr_first_value_boolean_true?(name, xpath) click to toggle source
# File lib/sslscan_wrapper/report.rb, line 31
def self.attr_first_value_boolean_true?(name, xpath)
  define_method(name) do
    node = @doc.xpath(xpath).first
    node.value.to_i == 1 unless node.nil?
  end
end
content_first_node_accessor(name, xpath) click to toggle source
# File lib/sslscan_wrapper/report.rb, line 38
def self.content_first_node_accessor(name, xpath)
  define_method(name) do
    node = @doc.xpath(xpath).first
    node.content unless node.nil?
  end
end
content_first_node_boolean_true?(name, xpath) click to toggle source
# File lib/sslscan_wrapper/report.rb, line 45
def self.content_first_node_boolean_true?(name, xpath)
  define_method(name) do
    node = @doc.xpath(xpath).first
    node.content == 'true' unless node.nil?
  end
end
new(output) click to toggle source

Initialize a new report object

Examples

content = File.read('report.xml')
SslscanWrapper::Report.new(content)

Returns a new SslscanWrapper::Report

# File lib/sslscan_wrapper/report.rb, line 19
def initialize(output)
  @body = output
  @doc = Nokogiri::XML(@body)
end

Public Instance Methods

certificate() click to toggle source

Return the parsed certificate blob as OpenSSL::X509::Certificate

# File lib/sslscan_wrapper/report.rb, line 133
def certificate
  node = @doc.xpath('//certificate/certificate-blob').first
  OpenSSL::X509::Certificate.new(node.content) unless node.nil?
end
heartbleed_vulnerable?() click to toggle source

Are there any heartblead vulnerable SSL/TLS protocol versions?

# File lib/sslscan_wrapper/report.rb, line 118
def heartbleed_vulnerable?
  @doc.xpath('//heartbleed[@vulnerable="1"]').count > 0
end
not_after() click to toggle source

Time the certificate is no longer valid

# File lib/sslscan_wrapper/report.rb, line 98
def not_after
  time_str = @doc.xpath('//certificate/not-valid-after').first.content
  Time.parse(time_str)
end
not_before() click to toggle source

Time the certificate starts to be valid

# File lib/sslscan_wrapper/report.rb, line 92
def not_before
  time_str = @doc.xpath('//certificate/not-valid-before').first.content
  Time.parse(time_str)
end
sslversions() click to toggle source

Returns a list of supported SSL protocol versions

# File lib/sslscan_wrapper/report.rb, line 123
def sslversions
  @doc.xpath('//cipher/@sslversion').map(&:value).uniq
end
support_cipher?(cipher) click to toggle source

Is the cipher supported?

# File lib/sslscan_wrapper/report.rb, line 107
def support_cipher?(cipher)
  @doc.xpath("//cipher[@cipher=$cipher]", nil, { cipher: cipher }).count > 0
end
support_sslversion?(version) click to toggle source

Check if a SSL protocol version is supported

# File lib/sslscan_wrapper/report.rb, line 128
def support_sslversion?(version)
  @doc.xpath("//cipher[@sslversion=$version]", nil, { version: version }).count > 0
end