Class: SSLyze::Protocol

Inherits:
Object
  • Object
show all
Defined in:
lib/sslyze/protocol.rb

Overview

Represents the <sslv2>, <sslv3>, <tls1>, <tls1_1>, <tlsv1_2> XML elements.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Protocol

Initializes the protocol.

Parameters:

  • node (Nokogiri::XML::Node)

    The XML element.



21
22
23
24
# File 'lib/sslyze/protocol.rb', line 21

def initialize(node)
  @node = node
  @name = @node.name.to_sym
end

Instance Attribute Details

#nameSymbol (readonly)

SSL protocol name.

Returns:

  • (Symbol)


13
14
15
# File 'lib/sslyze/protocol.rb', line 13

def name
  @name
end

Instance Method Details

#accepted_cipher_suitesArray<CipherSuite>

The accepted cipher suites.

Returns:



92
93
94
# File 'lib/sslyze/protocol.rb', line 92

def accepted_cipher_suites
  each_accepted_cipher_suite.to_a
end

#each_accepted_cipher_suite {|cipher_suite| ... } ⇒ Enumerator

Enumerates over every accepted cipher suite.

Yields:

  • (cipher_suite)

Yield Parameters:

Returns:

  • (Enumerator)


79
80
81
82
83
84
85
# File 'lib/sslyze/protocol.rb', line 79

def each_accepted_cipher_suite
  return enum_for(__method__) unless block_given?

  @node.search('acceptedCipherSuites/cipherSuite').each do |cipher_suite|
    yield CipherSuite.new(cipher_suite)
  end
end

#each_errorObject

TODO:

figure out what <errors /> contains.

Raises:

  • (NotImplemnetedError)


40
41
42
# File 'lib/sslyze/protocol.rb', line 40

def each_error
  raise(NotImplementedError,"#{__method__} not implemented")
end

#each_preferred_cipher_suite {|cipher_suite| ... } ⇒ Enumerator

Enumerates over every preferred cipher suite.

Yields:

  • (cipher_suite)

Yield Parameters:

Returns:

  • (Enumerator)


105
106
107
108
109
110
111
# File 'lib/sslyze/protocol.rb', line 105

def each_preferred_cipher_suite
  return enum_for(__method__) unless block_given?

  @node.search('preferredCipherSuites/cipherSuite').each do |cipher_suite|
    yield CipherSuite.new(cipher_suite)
  end
end

#each_rejected_cipher_suite {|cipher_suite| ... } ⇒ Enumerator

Enumerates over every rejected cipher suite.

Yields:

  • (cipher_suite)

Yield Parameters:

Returns:

  • (Enumerator)


53
54
55
56
57
58
59
# File 'lib/sslyze/protocol.rb', line 53

def each_rejected_cipher_suite
  return enum_for(__method__) unless block_given?

  @node.search('rejectedCipherSuites/cipherSuite').each do |cipher_suite|
    yield CipherSuite.new(cipher_suite)
  end
end

#preferred_cipher_suitesArray<CipherSuite>

The preferred cipher suites.

Returns:



118
119
120
# File 'lib/sslyze/protocol.rb', line 118

def preferred_cipher_suites
  each_preferred_cipher_suite.to_a
end

#rejected_cipher_suitesArray<CipherSuite>

The rejected cipher suites.

Returns:



66
67
68
# File 'lib/sslyze/protocol.rb', line 66

def rejected_cipher_suites
  each_rejected_cipher_suite.to_a
end

#supported?Boolean

Determines whether the protocol is supported.

Returns:

  • (Boolean)

    Specifies whether any cipher suite was accepted.



128
129
130
# File 'lib/sslyze/protocol.rb', line 128

def supported?
  each_accepted_cipher_suite.any?
end

#titleString

Descriptive title.

Returns:

  • (String)


31
32
33
# File 'lib/sslyze/protocol.rb', line 31

def title
  @title ||= @node['title']
end