Class: SSLyze::XML::Target

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

Overview

Represents the <target> XML element.

Constant Summary

Constants included from Types

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

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Target

Initializes the target.

Parameters:

  • node (Nokogiri::XML::Node)

    The <target> XML element.



30
31
32
# File 'lib/sslyze/xml/target.rb', line 30

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:



365
366
367
# File 'lib/sslyze/xml/target.rb', line 365

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

#certinfoCertinfo? Also known as: cert_info

Certificate information.

Returns:

Since:

  • 1.0.0



90
91
92
93
94
# File 'lib/sslyze/xml/target.rb', line 90

def certinfo
  @cert_info ||= if (element = @node.at_xpath('certinfo'))
                   Certinfo.new(element)
                 end
end

#compressionCompression?

Which compression algorithms are supported.

Returns:



77
78
79
80
81
# File 'lib/sslyze/xml/target.rb', line 77

def compression
  @compression ||= if (element = @node.at_xpath('compression'))
                     Compression.new(element)
                   end
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:



308
309
310
311
312
313
# File 'lib/sslyze/xml/target.rb', line 308

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:



241
242
243
244
245
246
# File 'lib/sslyze/xml/target.rb', line 241

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:



273
274
275
276
277
278
279
# File 'lib/sslyze/xml/target.rb', line 273

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

#fallbackFallback?

Returns:

Since:

  • 1.0.0



329
330
331
332
333
# File 'lib/sslyze/xml/target.rb', line 329

def fallback
  @fallback ||= if (element = @node.at_xpath('fallback'))
                  Fallback.new(element)
                end
end

#heartbleedHeartbleed?

Returns:

Since:

  • 1.0.0



103
104
105
106
107
# File 'lib/sslyze/xml/target.rb', line 103

def heartbleed
  @heartbleed ||= if (element = @node.at_xpath('heartbleed'))
                    Heartbleed.new(element)
                  end
end

#hostString

The host name of the target.

Returns:

  • (String)


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

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

#http_headersHTTPHeaders?

Returns:

Since:

  • 1.0.0



114
115
116
117
118
# File 'lib/sslyze/xml/target.rb', line 114

def http_headers
  @http_headers ||= if (element = @node.at_xpath('http_headers'))
                      HTTPHeaders.new(element)
                    end
end

#ipString

The IP address of the target.

Returns:

  • (String)


48
49
50
# File 'lib/sslyze/xml/target.rb', line 48

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

#ipaddrIPAddr

The IP address of the target.

Returns:

  • (IPAddr)

Since:

  • 1.0.0



59
60
61
# File 'lib/sslyze/xml/target.rb', line 59

def ipaddr
  IPAddr.new(ip)
end

#openssl_ccsOpenSSLCCS?

Returns:

Since:

  • 1.0.0



340
341
342
343
344
# File 'lib/sslyze/xml/target.rb', line 340

def openssl_ccs
  @openssl_ccs ||= if (element = @node.at_xpath('openssl_ccs'))
                     OpenSSLCCS.new(element)
                   end
end

#portInteger

The port number that was scanned.

Returns:

  • (Integer)


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

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

#protocolsArray<Protocol>

All supported SSL/TLS protocols.

Returns:



320
321
322
# File 'lib/sslyze/xml/target.rb', line 320

def protocols
  each_protocol.to_a
end

#renegReneg? Also known as: session_renegotiation

Specifies whether the service supports Session Renegotiation.

Returns:

Since:

  • 1.0.0



127
128
129
130
131
# File 'lib/sslyze/xml/target.rb', line 127

def reneg
  @reneg ||= if (element = @node.at_xpath('reneg'))
               Reneg.new(element)
             end
end

#resumResum?

Returns:

Since:

  • 1.0.0



140
141
142
143
144
# File 'lib/sslyze/xml/target.rb', line 140

def resum
  @resum ||= if (element = @node.at_xpath('resum'))
               Resum.new(element)
             end
end

#resum_rateResum? Also known as: session_resumption

Returns:

Since:

  • 1.0.0



153
154
155
156
157
# File 'lib/sslyze/xml/target.rb', line 153

def resum_rate
  @resum ||= if (element = @node.at_xpath('resum_rate'))
               ResumRate.new(element)
             end
end

#ssl_protocolsArray<Protocol>

All supported SSL protocols.

Returns:



253
254
255
# File 'lib/sslyze/xml/target.rb', line 253

def ssl_protocols
  each_ssl_protocol.to_a
end

#sslv2Protocol? Also known as: ssl_v2

SSLv2 protocol information.

Returns:



166
167
168
169
170
# File 'lib/sslyze/xml/target.rb', line 166

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

#sslv3Protocol? Also known as: ssl_v3

SSLv3 protocol information.

Returns:



179
180
181
182
183
# File 'lib/sslyze/xml/target.rb', line 179

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

#tls_protocolsArray<Protocol>

All supported TLS protocols.

Returns:



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

def tls_protocols
  each_tls_protocol.to_a
end

#tlsv1Protocol? Also known as: tls_v1

TLSv1 protocol information.

Returns:



192
193
194
195
196
# File 'lib/sslyze/xml/target.rb', line 192

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

#tlsv1_1Protocol? Also known as: tls_v1_1

TLSv1.1 protocol information.

Returns:



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

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

#tlsv1_2Protocol? Also known as: tls_v1_2

TLSv1.2 protocol information.

Returns:



218
219
220
221
222
# File 'lib/sslyze/xml/target.rb', line 218

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

#to_sString

Convert the target to a String.

Returns:

  • (String)

    The host and port.



352
353
354
# File 'lib/sslyze/xml/target.rb', line 352

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