Class: RubyNessus::Version1::Host
- Inherits:
-
Object
- Object
- RubyNessus::Version1::Host
- Includes:
- Enumerable
- Defined in:
- lib/ruby-nessus/version1/host.rb
Instance Method Summary collapse
-
#dns_name ⇒ String
Return the Host DNS Name.
-
#each_event {|prog| ... } ⇒ Object
Creates a new Event object to be parser.
-
#event_count ⇒ Integer
Return the total event count for a given host.
-
#events ⇒ Array<String>
Parses the events of the host.
-
#high_severity_events {|prog| ... } ⇒ Integer
Returns All High Event Objects For A Given Host.
-
#hostname ⇒ String
(also: #ip)
Return the Host Object hostname.
-
#informational_events {|prog| ... } ⇒ Integer
Returns All Informational Event Objects For A Given Host.
-
#initialize(host) ⇒ Host
constructor
Creates A New Host Object Host.new(object).
-
#low_severity_events {|prog| ... } ⇒ Integer
Returns All Low Event Objects For A Given Host.
-
#mac_addr ⇒ String
(also: #mac_address)
Return the Host Mac Address.
-
#medium_severity_events {|prog| ... } ⇒ Integer
Returns All Medium Event Objects For A Given Host.
-
#netbios_name ⇒ String
Return the Host Netbios Name.
-
#open_ports ⇒ Integer
Return the open ports for a given host object.
-
#os_name ⇒ String
(also: #operating_system)
Return the Host OS Name.
-
#scan_runtime ⇒ String
(also: #runtime)
Return the host run time.
-
#scan_start_time ⇒ DateTime
Return the host scan start time.
-
#scan_stop_time ⇒ DateTime
Return the host scan stop time.
- #to_s ⇒ Object
Constructor Details
#initialize(host) ⇒ Host
Creates A New Host Object Host.new(object)
12 13 14 |
# File 'lib/ruby-nessus/version1/host.rb', line 12 def initialize(host) @host = host end |
Instance Method Details
#dns_name ⇒ String
Return the Host DNS Name.
90 91 92 |
# File 'lib/ruby-nessus/version1/host.rb', line 90 def dns_name @dns_name ||= @host.at('dns_name').inner_text end |
#each_event {|prog| ... } ⇒ Object
Creates a new Event object to be parser
240 241 242 243 244 |
# File 'lib/ruby-nessus/version1/host.rb', line 240 def each_event(&block) @host.xpath('ReportItem').each do |event| yield(Event.new(event)) if block end end |
#event_count ⇒ Integer
Return the total event count for a given host.
227 228 229 |
# File 'lib/ruby-nessus/version1/host.rb', line 227 def event_count (low_severity_events.to_i + medium_severity_events.to_i + high_severity_events.to_i).to_i end |
#events ⇒ Array<String>
Parses the events of the host.
249 250 251 |
# File 'lib/ruby-nessus/version1/host.rb', line 249 def events to_enum(:each_event).to_a end |
#high_severity_events {|prog| ... } ⇒ Integer
Returns All High Event Objects For A Given Host.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ruby-nessus/version1/host.rb', line 205 def high_severity_events(&block) @high_severity_count = @host.at('num_hi').inner_text.to_i unless @high_severity_events @high_severity_events = [] @host.xpath('ReportItem').each do |event| next if event.at('severity').inner_text.to_i != 3 @high_severity_events << Event.new(event) end end @high_severity_events.each(&block) @high_severity_count end |
#hostname ⇒ String Also known as: ip
Return the Host Object hostname.
25 26 27 |
# File 'lib/ruby-nessus/version1/host.rb', line 25 def hostname @hostname ||= @host.at('HostName').inner_text end |
#informational_events {|prog| ... } ⇒ Integer
Returns All Informational Event Objects For A Given Host.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/ruby-nessus/version1/host.rb', line 124 def informational_events(&block) unless @informational_events @informational_events = [] @informational_event_count = 0 @host.xpath('ReportItem').each do |event| next if event.at('severity').inner_text.to_i != 0 @informational_events << Event.new(event) @informational_event_count += 1 end end @informational_events.each(&block) @informational_event_count end |
#low_severity_events {|prog| ... } ⇒ Integer
Returns All Low Event Objects For A Given Host.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/ruby-nessus/version1/host.rb', line 151 def low_severity_events(&block) @low_severity_count = @host.at('num_lo').inner_text.to_i unless @low_severity_events @low_severity_events = [] @host.xpath('ReportItem').each do |event| next if event.at('severity').inner_text.to_i != 1 @low_severity_events << Event.new(event) end end @low_severity_events.each(&block) @low_severity_count end |
#mac_addr ⇒ String Also known as: mac_address
Return the Host Mac Address.
80 81 82 |
# File 'lib/ruby-nessus/version1/host.rb', line 80 def mac_addr @mac_addr ||= @host.at('mac_addr').inner_text end |
#medium_severity_events {|prog| ... } ⇒ Integer
Returns All Medium Event Objects For A Given Host.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/ruby-nessus/version1/host.rb', line 178 def medium_severity_events(&block) @high_severity_count = @host.at('num_med').inner_text.to_i unless @medium_severity_events @medium_severity_events = [] @host.xpath('ReportItem').each do |event| next if event.at('severity').inner_text.to_i != 2 @medium_severity_events << Event.new(event) end end @medium_severity_events.each(&block) @high_severity_count end |
#netbios_name ⇒ String
Return the Host Netbios Name.
71 72 73 |
# File 'lib/ruby-nessus/version1/host.rb', line 71 def netbios_name @netbios_name ||= @host.at('netbios_name').inner_text end |
#open_ports ⇒ Integer
Return the open ports for a given host object.
109 110 111 |
# File 'lib/ruby-nessus/version1/host.rb', line 109 def open_ports @scanned_ports ||= @host.at('num_ports').inner_text.to_i end |
#os_name ⇒ String Also known as: operating_system
Return the Host OS Name.
99 100 101 |
# File 'lib/ruby-nessus/version1/host.rb', line 99 def os_name @os_name ||= @host.at('os_name').inner_text end |
#scan_runtime ⇒ String Also known as: runtime
Return the host run time.
61 62 63 |
# File 'lib/ruby-nessus/version1/host.rb', line 61 def scan_runtime get_runtime end |
#scan_start_time ⇒ DateTime
Return the host scan start time.
35 36 37 38 39 40 41 |
# File 'lib/ruby-nessus/version1/host.rb', line 35 def scan_start_time if @host.at('startTime').inner_text.empty? false else @host_scan_time = DateTime.strptime(@host.at('startTime').inner_text, '%a %b %d %H:%M:%S %Y') end end |
#scan_stop_time ⇒ DateTime
Return the host scan stop time.
48 49 50 51 52 53 54 |
# File 'lib/ruby-nessus/version1/host.rb', line 48 def scan_stop_time if @host.at('stopTime').inner_text.empty? false else @host_scan_time = DateTime.strptime(@host.at('stopTime').inner_text, '%a %b %d %H:%M:%S %Y') end end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/ruby-nessus/version1/host.rb', line 16 def to_s ip.to_s end |