class Prof::SSL::Results

Attributes

results[R]

Public Class Methods

new(results) click to toggle source
# File lib/prof/ssl/results.rb, line 14
def initialize(results)
  @results = Array(results).flatten
end

Public Instance Methods

protocols() click to toggle source
# File lib/prof/ssl/results.rb, line 39
def protocols
  results.map(&:protocol).uniq
end
supported_ciphers() click to toggle source
# File lib/prof/ssl/results.rb, line 43
def supported_ciphers
  @supported_ciphers ||= supported_results.map(&:cipher).uniq
end
supported_protocols() click to toggle source
# File lib/prof/ssl/results.rb, line 47
def supported_protocols
  @supported_protocols ||= supported_results.map(&:protocol).uniq
end
supports_cipher_set?(cipher_set) click to toggle source
# File lib/prof/ssl/results.rb, line 22
def supports_cipher_set?(cipher_set)
  expected_ciphers  = cipher_set.supported_ciphers
  expected_protocols = cipher_set.supported_protocols

  # 1. Every cipher in the set must exist in the results
  valid = expected_ciphers.all? { |expected_cipher| supported_ciphers.include? expected_cipher }

  # 2. No Ciphers exists in the results but not the cipher set
  valid &= supported_ciphers.all? { |supported_cipher| expected_ciphers.include? supported_cipher }

  # 3. No protocols in the cipher set that are not supported
  valid &= expected_protocols.all? { |expected_protocol| supported_protocols.include? expected_protocol }

  # 4. No protocols supported that are not in the cipher set
  valid &= supported_protocols.all? { |supported_protocol| expected_protocols.include? supported_protocol }
end
supports_protocol?(protocol) click to toggle source
# File lib/prof/ssl/results.rb, line 18
def supports_protocol?(protocol)
  results_for_protocol(protocol).any?(&:supported?)
end
unsupported_protocols() click to toggle source
# File lib/prof/ssl/results.rb, line 51
def unsupported_protocols
  protocols - supported_protocols
end

Private Instance Methods

results_for_protocol(protocol) click to toggle source
# File lib/prof/ssl/results.rb, line 67
def results_for_protocol(protocol)
  results.select do |result|
    result.protocol == protocol
  end
end
supported_results() click to toggle source
# File lib/prof/ssl/results.rb, line 59
def supported_results
  results.select(&:supported?)
end
unsupported_results() click to toggle source
# File lib/prof/ssl/results.rb, line 63
def unsupported_results
  results - supported_results
end