class Risu::Parsers::Nessus::NessusDocument
Attributes
Public Class Methods
new(document)
click to toggle source
Creates a instance of the NessusDocument
class
# File lib/risu/parsers/nessus/nessus_document.rb, line 31 def initialize document @document = document @new_tags = Array.new end
Public Instance Methods
fix_ips()
click to toggle source
Fixes the ip field if nil and replaces it with the name if its an ip
# File lib/risu/parsers/nessus/nessus_document.rb, line 77 def fix_ips @hosts = Host.all @hosts.each do |host| if host.ip == nil begin ip = IPAddr.new host.name host.ip = ip.to_string host.save rescue ArgumentError next end end end end
parse()
click to toggle source
Invokes the SAX parser on the XML document
# File lib/risu/parsers/nessus/nessus_document.rb, line 66 def parse @parser = LibXML::XML::SaxParser.file @document @parser.callbacks = NessusSaxListener.new @parser.parse #require 'pry' #binding.pry @new_tags == @parser.callbacks.new_tags end
valid?()
click to toggle source
Checks the validness of a NessusDocument
@return [Boolean] True if valid, False if invalid
# File lib/risu/parsers/nessus/nessus_document.rb, line 39 def valid? parser = nil if File.exist?(@document) parser = LibXML::XML::Parser.file @document elsif @document.class == "String" parser = LibXML::XML::Parser.string @document else return false end doc = parser.parse if doc.root.name == nil return false end if doc.root.name == "NessusClientData_v2" #.nessus v2 return true elsif doc.root.name == "NessusClientData" #.nessus v1 return false else return false end end