class TLSmap::App::Extractor::Sslyze

Parsing SSLyze

Public Class Methods

parse(file) click to toggle source

Extract the ciphers from the sslyze output file @param file [String] Path of the sslyze 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 120
def parse(file)
  data = Utils.json_load_file(file)
  extract_cipher(data)
end

Protected Class Methods

extract_cipher(json_data) click to toggle source

Extract the ciphers from the sslyze output file @param json_data [Hash] Ruby hash of the parsed JSON @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 128
def extract_cipher(json_data)
  ciphers = json_data['server_scan_results'][0]['scan_commands_results']
  raw = {
    'SSL2.0' => ciphers['ssl_2_0_cipher_suites']['accepted_cipher_suites'],
    'SSL3.0' => ciphers['ssl_3_0_cipher_suites']['accepted_cipher_suites'],
    'TLS1.0' => ciphers['tls_1_0_cipher_suites']['accepted_cipher_suites'],
    'TLS1.1' => ciphers['tls_1_1_cipher_suites']['accepted_cipher_suites'],
    'TLS1.2' => ciphers['tls_1_2_cipher_suites']['accepted_cipher_suites'],
    'TLS1.3' => ciphers['tls_1_3_cipher_suites']['accepted_cipher_suites']
  }
  raw.transform_values { |v| v.empty? ? v : v.map { |x| x['cipher_suite']['name'] } }
end