Class: TLSmap::App::Extractor::SsllabsScan

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

Overview

Parsing ssllabs-scan

Class Method Summary collapse

Class Method Details

.extract_cipher(json_data) ⇒ Array<String>

Extract the ciphers from the ssllabs-scan output file

Parameters:

  • json_data (Hash)

    Ruby hash of the parsed JSON

Returns:

  • (Array<String>)

    Cipher array (IANA names)



249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/tls_map/app/extractor/extractor.rb', line 249

def extract_cipher(json_data) # rubocop:disable Metrics/MethodLength
  raw = {
    'SSL2.0' => [], 'SSL3.0' => [],
    'TLS1.0' => [], 'TLS1.1' => [], 'TLS1.2' => [], 'TLS1.3' => []
  }
  json_data[0]['endpoints'].each do |endpoint|
    endpoint['details']['suites'].each do |suite|
      suite['list'].each do |cipher|
        raw[id2prot(suite['protocol'])].push(cipher['name'])
      end
    end
  end
  raw.transform_values(&:uniq)
end

.id2prot(id) ⇒ String

Convert ssllabs-scan protocol id to protocol name in TLSmap format

Parameters:

  • id (String)

    ssllabs-scan protocol id

Returns:

  • (String)

    protocol name in TLSmap format



267
268
269
270
271
272
273
# File 'lib/tls_map/app/extractor/extractor.rb', line 267

def id2prot(id)
  prot = {
    512 => 'SSL2.0', 768 => 'SSL3.0', 769 => 'TLS1.0',
    770 => 'TLS1.1', 771 => 'TLS1.2', 772 => 'TLS1.3'
  }
  prot[id]
end

.parse(file) ⇒ Array<String>

Extract the ciphers from the ssllabs-scan output file

Parameters:

  • file (String)

    Path of the ssllabs-scan output file, beware of the format expected. See TLSmap::App::Extractor

Returns:

  • (Array<String>)

    Cipher array (IANA names)



241
242
243
244
# File 'lib/tls_map/app/extractor/extractor.rb', line 241

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