Class: SSLyze::Target

Inherits:
Object
  • Object
show all
Includes:
Types
Defined in:
lib/sslyze/target.rb

Overview

Represents the <target> XML element.

Defined Under Namespace

Classes: SessionRenegotiation

Constant Summary

Constants included from Types

SSLyze::Types::Boolean, SSLyze::Types::None

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Target

Initializes the target.

Parameters:

  • node (Nokogiri::XML::Node)

    The <target> XML element.



19
20
21
# File 'lib/sslyze/target.rb', line 19

def initialize(node)
  @node = node
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the other target to this target.

Parameters:

  • other (Target)

    The other target.

Returns:

  • (Boolean)

    Whether the other target has the same host and port.



300
301
302
# File 'lib/sslyze/target.rb', line 300

def ==(other)
  other.kind_of?(self.class) && other.host == host && other.port == port
end

#cert_infoCertInfo?

Certificate information.

Returns:



55
56
57
58
59
# File 'lib/sslyze/target.rb', line 55

def cert_info
  @cert_info ||= if (certinfo = @node.at('certinfo'))
                   CertInfo.new(certinfo)
                 end
end

#compressionHash{Symbol => Boolean}

Which compression algorithms are supported.

Returns:

  • (Hash{Symbol => Boolean})

    The algorithm name and support status.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/sslyze/target.rb', line 67

def compression
  unless @compression
    @compression = {}

    @node.search('compression/compressionMethod').map do |compression|
      type      = compression['type'].downcase.to_sym
      supported = Boolean[compression['isSupported']]

      @compression[type] = supported
    end
  end

  return @compression
end

#each_protocol {|protocol| ... } ⇒ Enumerator

Iterates over every SSL/TLS protocol.

Yields:

  • (protocol)

    The given block will be passed each SSL/TLS protocol.

Yield Parameters:

  • protocol (Protocol)

    A SSL/TLS protocol.

Returns:

  • (Enumerator)

    If a no block was given, an Enumerator will be returned.

See Also:

  • {#sslv3}, {#tlsv1}, {#tlsv1_1}, {#tlsv1_2}


265
266
267
268
269
270
# File 'lib/sslyze/target.rb', line 265

def each_protocol(&block)
  return enum_for(__method__) unless block

  each_ssl_protocol(&block)
  each_tls_protocol(&block)
end

#each_ssl_protocol {|protocol| ... } ⇒ Enumerator

Iterates over every SSL protocol.

Yields:

  • (protocol)

    The given block will be passed each SSL protocol.

Yield Parameters:

  • protocol (Protocol)

    A SSL protocol.

Returns:

  • (Enumerator)

    If a no block was given, an Enumerator will be returned.

See Also:

  • {#sslv3}


204
205
206
207
208
209
# File 'lib/sslyze/target.rb', line 204

def each_ssl_protocol
  return enum_for(__method__) unless block_given?

  yield sslv2 if sslv2
  yield sslv3 if sslv3
end

#each_tls_protocol {|protocol| ... } ⇒ Enumerator

Iterates over every TLS protocol.

Yields:

  • (protocol)

    The given block will be passed each TLS protocol.

Yield Parameters:

  • protocol (Protocol)

    A TLS protocol.

Returns:

  • (Enumerator)

    If a no block was given, an Enumerator will be returned.

See Also:

  • {#tlsv1_1}, {#tlsv1_2}


234
235
236
237
238
239
240
# File 'lib/sslyze/target.rb', line 234

def each_tls_protocol
  return enum_for(__method__) unless block_given?

  yield tlsv1 if tlsv1
  yield tlsv1_1 if tlsv1_1
  yield tlsv1_2 if tlsv1_2
end

#heartbleed?Boolean?

Specifies whether the service was vulnerable to Heartbleed.

Returns:



87
88
89
90
91
# File 'lib/sslyze/target.rb', line 87

def heartbleed?
  if (heartbleed = @node.at('heartbleed/openSslHeartbleed'))
    Boolean[heartbleed['isVulnerable']]
  end
end

#hostString

The host name of the target.

Returns:

  • (String)


28
29
30
# File 'lib/sslyze/target.rb', line 28

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

#ipString

The IP address of the target.

Returns:

  • (String)


37
38
39
# File 'lib/sslyze/target.rb', line 37

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

#portInteger

The port number that was scanned.

Returns:

  • (Integer)


46
47
48
# File 'lib/sslyze/target.rb', line 46

def port
  @port ||= @node['port'].to_i
end

#protocolsArray<Protocol>

All supported SSL/TLS protocols.

Returns:



277
278
279
# File 'lib/sslyze/target.rb', line 277

def protocols
  each_protocol.to_a
end

#session_renegotiationSessionRenegotiation?

Specifies whether the service supports Session Renegotiation.

Returns:



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/sslyze/target.rb', line 113

def session_renegotiation
  @session_renegotiation ||= (
    if (sessionRenegotiation = @node.at('reneg/sessionRenegotiation'))

      SessionRenegotiation.new(
        Boolean[sessionRenegotiation['canBeClientInitiated']],
        Boolean[sessionRenegotiation['isSecure']]
      )
    end
  )
end

#ssl_protocolsArray<Protocol>

All supported SSL protocols.

Returns:



216
217
218
# File 'lib/sslyze/target.rb', line 216

def ssl_protocols
  each_ssl_protocol.to_a
end

#sslv2Protocol? Also known as: ssl_v2

SSLv2 protocol information.

Returns:



130
131
132
133
134
# File 'lib/sslyze/target.rb', line 130

def sslv2
  @sslv2 ||= if (node = @node.at('sslv2'))
               Protocol.new(node)
             end
end

#sslv3Protocol? Also known as: ssl_v3

SSLv3 protocol information.

Returns:



143
144
145
146
147
# File 'lib/sslyze/target.rb', line 143

def sslv3
  @sslv3 ||= if (node = @node.at('sslv3'))
               Protocol.new(node)
             end
end

#tls_protocolsArray<Protocol>

All supported TLS protocols.

Returns:



247
248
249
# File 'lib/sslyze/target.rb', line 247

def tls_protocols
  each_tls_protocol.to_a
end

#tlsv1Protocol? Also known as: tls_v1

TLSv1 protocol information.

Returns:



156
157
158
159
160
# File 'lib/sslyze/target.rb', line 156

def tlsv1
  @tlsv1 ||= if (node = @node.at('tlsv1'))
               Protocol.new(node)
             end
end

#tlsv1_1Protocol? Also known as: tls_v1_1

TLSv1.1 protocol information.

Returns:



169
170
171
172
173
# File 'lib/sslyze/target.rb', line 169

def tlsv1_1
  @tlsv1_1 ||= if (node = @node.at('tlsv1_1'))
                 Protocol.new(node)
               end
end

#tlsv1_2Protocol? Also known as: tls_v1_2

TLSv1.2 protocol information.

Returns:



182
183
184
185
186
# File 'lib/sslyze/target.rb', line 182

def tlsv1_2
  @tlsv1_2 ||= if (node = @node.at('tlsv1_2'))
                 Protocol.new(node)
               end
end

#to_sString

Convert the target to a String.

Returns:

  • (String)

    The host and port.



287
288
289
# File 'lib/sslyze/target.rb', line 287

def to_s
  "#{host}:#{port}"
end