Class: TLSmap::App::Extractor::Sslyze

Inherits:
Object
  • Object
show all
Defined in:
lib/tls_map/extractor.rb

Overview

Parsing SSLyze

Class Method Summary collapse

Class Method Details

.extract_cipher(json_data) ⇒ Array<String>

Extract the ciphers from the sslyze output file

Parameters:

  • json_data (Hash)

    Ruby hash of the parsed JSON

Returns:

  • (Array<String>)

    Cipher array (IANA names)



128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/tls_map/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

.parse(file) ⇒ Array<String>

Extract the ciphers from the sslyze output file

Parameters:

Returns:

  • (Array<String>)

    Cipher array (IANA names)



120
121
122
123
# File 'lib/tls_map/extractor.rb', line 120

def parse(file)
  data = Utils.json_load_file(file)
  extract_cipher(data)
end