mephux/ruby-nessus — Issue #3: Nessus XML issues (no hostname or ip tag)
Author: yowie
Created: 2011-10-20 03:08:23+00:00
State: open

I've noticed a bug in the Nessus XML output that has no hostname or ip tags (even though the ReportHost tag is the IP address).

e.g:

Wed Oct 12 10:48:12 2011
AIX 5.2
CatalystOS 6.3
00:23:7d:ec:d1:80
Wed Oct 12 10:27:34 2011

As a result, the parser was missing all my hosts without a hostname! :(

I am new to ruby, so this is probably so horribly wrong that i should be shot - but I've made the following changes to make it 'work':

version2.rb:

def each_host(&block)
hosts = []
@xml.xpath("//ReportHost").each do |host|
hosts << host['name'] if host['name']
#block.call(Host.new(host)) if block
block.call(Host.new(host, host['name'])) if block
end
hosts
end

host.rb:
def initialize(host, temp_hostname)
@host = host
@t_hostname = temp_hostname
end

def hostname
if (host = @host.at('tag[name=host-fqdn]'))
host.inner_text
else
@t_hostname
end

end

Would love to see how this should be done properly.. I'm only a few days into my ruby so hopefully there is a better way!