Class: SSLyze::XML
Overview
Represents the XML output from sslyze.
Constant Summary
Constants included from Types
Class Method Summary collapse
-
.open(path) ⇒ XML
Opens the XML file.
-
.parse(xml) ⇒ XML
Parses the XML.
Instance Method Summary collapse
-
#default_timeout ⇒ Integer
The default timeout used.
-
#each_invalid_target {|invalidtarget| ... } ⇒ Enumerator
Enumerates over each invalid target.
-
#each_target {|target| ... } ⇒ Enumerator
(also: #each)
Enumerates over each target.
-
#https_tunnel ⇒ Boolean
Whether an HTTPS tunnel was used.
-
#initialize(doc) ⇒ XML
constructor
Initializes the XML.
- #invalid_targets ⇒ Array<InvalidTarget>
-
#start_tls ⇒ Boolean
Specifies whether STARTTLS was enabled.
-
#target ⇒ Target?
The first target.
- #targets ⇒ Array<Target>
-
#total_scan_time ⇒ Float
Duration of the scan.
-
#version ⇒ String
The version of the XML output.
Constructor Details
#initialize(doc) ⇒ XML
Initializes the XML.
20 21 22 |
# File 'lib/sslyze/xml.rb', line 20 def initialize(doc) @doc = doc end |
Class Method Details
.open(path) ⇒ XML
Opens the XML file.
44 45 46 |
# File 'lib/sslyze/xml.rb', line 44 def self.open(path) new(File.open(path) { |file| Nokogiri::XML(file) }) end |
.parse(xml) ⇒ XML
Parses the XML.
32 33 34 |
# File 'lib/sslyze/xml.rb', line 32 def self.parse(xml) new(Nokogiri::XML.parse(xml)) end |
Instance Method Details
#default_timeout ⇒ Integer
The default timeout used.
62 63 64 |
# File 'lib/sslyze/xml.rb', line 62 def default_timeout @default_time ||= @doc.at('/document/results/@defaultTimeout').value.to_i end |
#each_invalid_target {|invalidtarget| ... } ⇒ Enumerator
Enumerates over each invalid target.
114 115 116 117 118 119 120 |
# File 'lib/sslyze/xml.rb', line 114 def each_invalid_target return enum_for(__method__) unless block_given? @doc.search('invalidTargets/invalidTarget').each do |inval| yield InvalidTarget.new(inval) end end |
#each_target {|target| ... } ⇒ Enumerator Also known as: each
Enumerates over each target.
131 132 133 134 135 136 137 |
# File 'lib/sslyze/xml.rb', line 131 def each_target return enum_for(__method__) unless block_given? @doc.search('/document/results/target').each do |target| yield Target.new(target) end end |
#https_tunnel ⇒ Boolean
Whether an HTTPS tunnel was used.
71 72 73 |
# File 'lib/sslyze/xml.rb', line 71 def https_tunnel @https_tunnel ||= Boolean[@doc.at('/document/results/@httpsTunnel').value] end |
#invalid_targets ⇒ Array<InvalidTarget>
100 101 102 |
# File 'lib/sslyze/xml.rb', line 100 def invalid_targets each_invalid_target.to_a end |
#start_tls ⇒ Boolean
Specifies whether STARTTLS was enabled.
80 81 82 |
# File 'lib/sslyze/xml.rb', line 80 def start_tls @start_tls ||= Boolean[@doc.at('/document/results/@startTLS').value] end |
#target ⇒ Target?
The first target.
155 156 157 |
# File 'lib/sslyze/xml.rb', line 155 def target each_target.first end |
#targets ⇒ Array<Target>
146 147 148 |
# File 'lib/sslyze/xml.rb', line 146 def targets each_target.to_a end |
#total_scan_time ⇒ Float
Duration of the scan.
89 90 91 |
# File 'lib/sslyze/xml.rb', line 89 def total_scan_time @start_tls ||= @doc.at('/document/results/@totalScanTime').value.to_f end |
#version ⇒ String
The version of the XML output.
53 54 55 |
# File 'lib/sslyze/xml.rb', line 53 def version @version ||= @doc.at('/document/@SSLyzeVersion').value.split(' ',2).last end |