Class: Nessus::Version1::Host
- Inherits:
-
Object
- Object
- Nessus::Version1::Host
- Includes:
- Enumerable
- Defined in:
- lib/gemcache/ruby-nessus/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)
11 12 13 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 11 def initialize(host) @host = host end |
Instance Method Details
#dns_name ⇒ String
Return the Host DNS Name.
89 90 91 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 89 def dns_name @dns_name ||= @host.at('dns_name').inner_text end |
#each_event {|prog| ... } ⇒ Object
Creates a new Event object to be parser
242 243 244 245 246 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 242 def each_event(&block) @host.xpath("ReportItem").each do |event| block.call(Event.new(event)) if block end end |
#event_count ⇒ Integer
Return the total event count for a given host.
229 230 231 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 229 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.
251 252 253 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 251 def events Enumerator.new(self,:each_event).to_a end |
#high_severity_events {|prog| ... } ⇒ Integer
Returns All High Event Objects For A Given Host.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 206 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) return @high_severity_count end |
#hostname ⇒ String Also known as: ip
Return the Host Object hostname.
24 25 26 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 24 def hostname @hostname ||= @host.at('HostName').inner_text end |
#informational_events {|prog| ... } ⇒ Integer
Returns All Informational Event Objects For A Given Host.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 123 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) return @informational_event_count end |
#low_severity_events {|prog| ... } ⇒ Integer
Returns All Low Event Objects For A Given Host.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 150 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) return @low_severity_count end |
#mac_addr ⇒ String Also known as: mac_address
Return the Host Mac Address.
79 80 81 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 79 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 194 |
# File 'lib/gemcache/ruby-nessus/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) return @high_severity_count end |
#netbios_name ⇒ String
Return the Host Netbios Name.
70 71 72 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 70 def netbios_name @netbios_name ||= @host.at('netbios_name').inner_text end |
#open_ports ⇒ Integer
Return the open ports for a given host object.
108 109 110 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 108 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.
98 99 100 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 98 def os_name @os_name ||= @host.at('os_name').inner_text end |
#scan_runtime ⇒ String Also known as: runtime
Return the host run time.
60 61 62 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 60 def scan_runtime get_runtime end |
#scan_start_time ⇒ DateTime
Return the host scan start time.
34 35 36 37 38 39 40 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 34 def scan_start_time if @host.at('startTime').inner_text.blank? return false else @host_scan_time = DateTime.strptime(@host.at('startTime').inner_text, fmt='%a %b %d %H:%M:%S %Y') end end |
#scan_stop_time ⇒ DateTime
Return the host scan stop time.
47 48 49 50 51 52 53 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 47 def scan_stop_time if @host.at('stopTime').inner_text.blank? return false else @host_scan_time = DateTime.strptime(@host.at('stopTime').inner_text, fmt='%a %b %d %H:%M:%S %Y') end end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/gemcache/ruby-nessus/ruby-nessus/Version1/host.rb', line 15 def to_s "#{ip}" end |