Class: Nikto::XML
- Inherits:
-
Object
- Object
- Nikto::XML
- Defined in:
- lib/nikto/xml.rb,
lib/nikto/xml/item.rb,
lib/nikto/xml/statistics.rb,
lib/nikto/xml/scan_details.rb
Overview
Defined Under Namespace
Classes: Item, ScanDetails, Statistics
Instance Attribute Summary collapse
-
#doc ⇒ Nokogiri::XML
readonly
private
The parsed XML document.
-
#path ⇒ String?
readonly
The path to the XML file.
Class Method Summary collapse
-
.open(path) {|xml| ... } ⇒ XML
Opens an parses an XML file.
-
.parse(xml) {|xml| ... } ⇒ XML
Parses the given XML String.
Instance Method Summary collapse
-
#each_scan_details {|scan_details| ... } ⇒ Enumerator
(also: #each_target)
Parses each
scandetails
child element. -
#hosts_test ⇒ Integer
The
hoststest
value. -
#initialize(doc, path: nil) {|xml| ... } ⇒ XML
constructor
private
Creates a new XML object.
-
#nikto_xml_version ⇒ String
The Nikto XML schema version.
-
#options ⇒ String
Additional command-line options passed to
nikto
. -
#scan_details ⇒ Array<ScanDetails>
(also: #targets)
The scan details.
-
#scan_elapsed ⇒ String
The duration of the scan.
-
#scan_end ⇒ Time
When the scan completed.
-
#scan_start ⇒ Time
When the scan started.
-
#target ⇒ ScanDetails?
The first scan details object.
-
#to_s ⇒ String
Converts the XML object to a String.
Constructor Details
#initialize(doc, path: nil) {|xml| ... } ⇒ XML
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new XML object.
58 59 60 61 62 63 |
# File 'lib/nikto/xml.rb', line 58 def initialize(doc, path: nil) @doc = doc @path = File.(path) if path yield self if block_given? end |
Instance Attribute Details
#doc ⇒ Nokogiri::XML (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The parsed XML document.
33 34 35 |
# File 'lib/nikto/xml.rb', line 33 def doc @doc end |
#path ⇒ String? (readonly)
The path to the XML file.
38 39 40 |
# File 'lib/nikto/xml.rb', line 38 def path @path end |
Class Method Details
.open(path) {|xml| ... } ⇒ XML
Opens an parses an XML file.
105 106 107 108 109 110 |
# File 'lib/nikto/xml.rb', line 105 def self.open(path,&block) path = File.(path) doc = Nokogiri::XML(File.open(path)) new(doc, path: path, &block) end |
.parse(xml) {|xml| ... } ⇒ XML
Parses the given XML String.
83 84 85 |
# File 'lib/nikto/xml.rb', line 83 def self.parse(xml,&block) new(Nokogiri::XML(xml),&block) end |
Instance Method Details
#each_scan_details {|scan_details| ... } ⇒ Enumerator Also known as: each_target
Parses each scandetails
child element.
184 185 186 187 188 189 190 |
# File 'lib/nikto/xml.rb', line 184 def each_scan_details return enum_for(__method__) unless block_given? @doc.xpath('/niktoscan/scandetails').each do |node| yield ScanDetails.new(node) end end |
#hosts_test ⇒ Integer
The hoststest
value.
118 119 120 |
# File 'lib/nikto/xml.rb', line 118 def hosts_test @hosts_test ||= @doc.root['@hoststest'].to_i end |
#nikto_xml_version ⇒ String
The Nikto XML schema version.
168 169 170 |
# File 'lib/nikto/xml.rb', line 168 def nikto_xml_version @doc.root['nxmlversion'] end |
#options ⇒ String
Additional command-line options passed to nikto
.
128 129 130 |
# File 'lib/nikto/xml.rb', line 128 def @doc.root['options'] end |
#scan_details ⇒ Array<ScanDetails> Also known as: targets
The scan details.
197 198 199 |
# File 'lib/nikto/xml.rb', line 197 def scan_details each_scan_details.to_a end |
#scan_elapsed ⇒ String
The duration of the scan.
158 159 160 |
# File 'lib/nikto/xml.rb', line 158 def scan_elapsed @doc.root['scanelapsed'] end |
#scan_end ⇒ Time
When the scan completed.
148 149 150 |
# File 'lib/nikto/xml.rb', line 148 def scan_end @scan_end ||= Time.parse(@doc.root['scanend']) end |
#scan_start ⇒ Time
When the scan started.
138 139 140 |
# File 'lib/nikto/xml.rb', line 138 def scan_start @scan_start ||= Time.parse(@doc.root['scanstart']) end |
#target ⇒ ScanDetails?
The first scan details object.
210 211 212 |
# File 'lib/nikto/xml.rb', line 210 def target each_target.first end |
#to_s ⇒ String
Converts the XML object to a String.
221 222 223 224 225 226 227 |
# File 'lib/nikto/xml.rb', line 221 def to_s if @path @path else @doc.to_s end end |