class TLSmap::App::Extractor

External tools output data extractor

Output files from [SSLyze] (JSON), [sslscan2] (XML), [testssl.sh] (JSON), [ssllabs-scan] (JSON)

[1]:github.com/nabla-c0d3/sslyze [2]:github.com/rbsec/sslscan [3]:github.com/drwetter/testssl.sh [4]:github.com/ssllabs/ssllabs-scan

Example of commands:

Constants

CMD

Commands for {helper}

Attributes

ciphers[R]

Get the list of ciphers extracted from the tool output file @return [Array<String>] Cipher array (IANA names)

Public Class Methods

new() click to toggle source

Initialize {TLSmap::App::Extractor} instance

# File lib/tls_map/app/extractor/extractor.rb, line 36
def initialize
  @ciphers = []
end

Public Instance Methods

parse(tool, file) click to toggle source

Extract the ciphers from the tool output file @param tool [String] Possible values: `sslyze`, `sslscan2`, `testssl`, `ssllabs-scan` @param file [String] Path of the tool 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 80
def parse(tool, file)
  # Convert string to class
  @ciphers = Object.const_get("TLSmap::App::Extractor::#{normalize(tool)}").parse(file)
rescue StandardError
  warn helper(tool)
end
ssl20() click to toggle source

Return only the SSL 2.0 ciphers @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 42
def ssl20
  @ciphers['SSL2.0']
end
ssl30() click to toggle source

Return only the SSL 3.0 ciphers @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 48
def ssl30
  @ciphers['SSL3.0']
end
tls10() click to toggle source

Return only the TLS 1.0 ciphers @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 54
def tls10
  @ciphers['TLS1.0']
end
tls11() click to toggle source

Return only the TLS 1.1 ciphers @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 60
def tls11
  @ciphers['TLS1.1']
end
tls12() click to toggle source

Return only the TLS 1.2 ciphers @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 66
def tls12
  @ciphers['TLS1.2']
end
tls13() click to toggle source

Return only the TLS 1.3 ciphers @return [Array<String>] Cipher array (IANA names)

# File lib/tls_map/app/extractor/extractor.rb, line 72
def tls13
  @ciphers['TLS1.3']
end

Protected Instance Methods

helper(tool) click to toggle source

Get the external tool command used to generate the expected result format @param tool [String] Possible values: `sslyze`, `sslscan2`, `testssl`, `ssllabs-scan` @return [String] external tool command used to generate the expected result format used in input of the extract

command (CLI) / {parse} method (library)
# File lib/tls_map/app/extractor/extractor.rb, line 99
def helper(tool)
  intro = 'You may not be provinding the right format.'
  outro = 'See https://noraj.github.io/tls-map/yard/TLSmap/App/Extractor'
  "#{intro}\nUse this command: #{CMD[tool]}\n#{outro}"
end
normalize(tool) click to toggle source

Convert cmdline tool name to Class name

# File lib/tls_map/app/extractor/extractor.rb, line 106
def normalize(tool)
  tool.split('-').map(&:capitalize).join
end