Class: SSLyze::XML::Protocol

Inherits:
Plugin
  • Object
show all
Includes:
Types
Defined in:
lib/sslyze/xml/protocol.rb,
lib/sslyze/xml/protocol/cipher_suite.rb,
lib/sslyze/xml/protocol/cipher_suite/key_exchange.rb

Overview

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

Defined Under Namespace

Classes: CipherSuite

Constant Summary

Constants included from Types

Types::Boolean, Types::None

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes::Exception

#exception, #exception?

Methods included from Attributes::Title

#title, #to_s

Constructor Details

#initialize(node) ⇒ Protocol

Initializes the protocol.

Parameters:

  • node (Nokogiri::XML::Node)

    The XML element.



26
27
28
29
# File 'lib/sslyze/xml/protocol.rb', line 26

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

Instance Attribute Details

#nameSymbol (readonly)

SSL protocol name.

Returns:

  • (Symbol)


18
19
20
# File 'lib/sslyze/xml/protocol.rb', line 18

def name
  @name
end

Instance Method Details

#accepted_cipher_suitesArray<CipherSuite>

The accepted cipher suites.

Returns:



94
95
96
# File 'lib/sslyze/xml/protocol.rb', line 94

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)


81
82
83
84
85
86
87
# File 'lib/sslyze/xml/protocol.rb', line 81

def each_accepted_cipher_suite
  return enum_for(__method__) unless block_given?

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

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

Enumerates over every errored cipher suite.

Yields:

  • (cipher_suite)

Yield Parameters:

Returns:

  • (Enumerator)

Since:

  • 1.0.0



122
123
124
125
126
127
128
# File 'lib/sslyze/xml/protocol.rb', line 122

def each_error
  return enum_for(__method__) unless block_given?

  @node.xpath('errors/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)


55
56
57
58
59
60
61
# File 'lib/sslyze/xml/protocol.rb', line 55

def each_rejected_cipher_suite
  return enum_for(__method__) unless block_given?

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

#errorsArray<CipherSuite>

The errored cipher suites.

Returns:

Since:

  • 1.0.0



137
138
139
# File 'lib/sslyze/xml/protocol.rb', line 137

def errors
  each_error.to_a
end

#is_protocol_supported?Boolean Also known as: is_supported?, supported?

Determines whether the protocol is supported.

Returns:

  • (Boolean)

    Specifies whether any cipher suite was accepted.

Since:

  • 1.0.0



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

def is_protocol_supported?
  Boolean[@node['isProtocolSupported']]
end

#preferred_cipher_suiteCipherSuite?

The preferred cipher suite.

Returns:

Since:

  • 1.0.0



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

def preferred_cipher_suite
  @preferred_cipher_suite ||= if (element = @node.at_xpath('preferredCipherSuite/cipherSuite'))
                                CipherSuite.new(element)
                              end
end

#rejected_cipher_suitesArray<CipherSuite>

The rejected cipher suites.

Returns:



68
69
70
# File 'lib/sslyze/xml/protocol.rb', line 68

def rejected_cipher_suites
  each_rejected_cipher_suite.to_a
end