Class: RubyNessus::Parse
- Inherits:
-
Object
- Object
- RubyNessus::Parse
- Defined in:
- lib/ruby-nessus/parse.rb
Instance Method Summary collapse
-
#detect_version ⇒ Object
Try to detection version with the XML given.
-
#initialize(file = nil, options = {}) {|@xml_parser| ... } ⇒ Parse
constructor
A new instance of Parse.
-
#scan ⇒ Object
Retrive scan from file.
Constructor Details
#initialize(file = nil, options = {}) {|@xml_parser| ... } ⇒ Parse
Returns a new instance of Parse.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby-nessus/parse.rb', line 13 def initialize(file = nil, = {}, &block) doc = file ? File.read(file) : [:xml] @xml = Nokogiri::XML.parse(doc) @version = [:version] || detect_version @xml_parser = case @version when 1 Version1::XML.new(@xml) when 2 Version2::XML.new(@xml) else raise 'Error: Supported .Nessus Version are 1 and 2.' end yield(@xml_parser) if block end |
Instance Method Details
#detect_version ⇒ Object
Try to detection version with the XML given
36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby-nessus/parse.rb', line 36 def detect_version if @xml.at('NessusClientData') 1 elsif @xml.at('NessusClientData_v2') 2 else raise 'Error: Supported .Nessus Version are 1 and 2.' end end |
#scan ⇒ Object
Retrive scan from file
31 32 33 |
# File 'lib/ruby-nessus/parse.rb', line 31 def scan @xml_parser end |