Class: Prof::SSL::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/prof/ssl/results.rb

Instance Method Summary collapse

Constructor Details

#initialize(results) ⇒ Results

Returns a new instance of Results.



14
15
16
# File 'lib/prof/ssl/results.rb', line 14

def initialize(results)
  @results = Array(results).flatten
end

Instance Method Details

#protocolsObject



39
40
41
# File 'lib/prof/ssl/results.rb', line 39

def protocols
  results.map(&:protocol).uniq
end

#supported_ciphersObject



43
44
45
# File 'lib/prof/ssl/results.rb', line 43

def supported_ciphers
  @supported_ciphers ||= supported_results.map(&:cipher).uniq
end

#supported_protocolsObject



47
48
49
# File 'lib/prof/ssl/results.rb', line 47

def supported_protocols
  @supported_protocols ||= supported_results.map(&:protocol).uniq
end

#supports_cipher_set?(cipher_set) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/prof/ssl/results.rb', line 18

def supports_protocol?(protocol)
  results_for_protocol(protocol).any?(&:supported?)
end

#unsupported_protocolsObject



51
52
53
# File 'lib/prof/ssl/results.rb', line 51

def unsupported_protocols
  protocols - supported_protocols
end