class TLSmap::App::Extractor::Sslscan2

Parsing sslscan2

Public Class Methods

parse(file, online = false) click to toggle source

Extract the ciphers from the sslscan2 output file @param file [String] Path of the sslscan2 output file, beware of the format expected.

See {TLSmap::App::Extractor}

@return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 152
def parse(file, online = false)
  doc = REXML::Document.new(File.new(file))
  extract_cipher(doc, online)
end

Protected Class Methods

extract_cipher(xml_doc, online = false) click to toggle source

Extract the ciphers from the sslscan2 output file @param xml_doc [REXML::Document] XML document as returned by `REXML::Document` @param online By default use the offline mode with {TLSmap::CLI} for better performance.

Online mode will use {TLSmap::App} and fetch upstream resources to get latest updates but is a lot slower.

@return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 162
def extract_cipher(xml_doc, online = false) # rubocop:disable Metrics/MethodLength
  raw = {
    'SSL2.0' => [], 'SSL3.0' => [],
    'TLS1.0' => [], 'TLS1.1' => [], 'TLS1.2' => [], 'TLS1.3' => []
  }
  tm = online ? TLSmap::App.new : TLSmap::CLI.new
  xml_doc.root.each_element('//cipher') do |node|
    sslv = node.attributes['sslversion'].gsub('v', '')
    cipher = tm.search(:codepoint, node.attributes['id'][2..], :iana)[:iana]
    raw[sslv].push(cipher)
  end
  raw
end