Class: Rex::Parser::IP360ASPLXMLStreamParser
- Inherits:
-
Object
- Object
- Rex::Parser::IP360ASPLXMLStreamParser
- Defined in:
- lib/rex/parser/ip360_aspl_xml.rb
Instance Attribute Summary collapse
-
#on_found_aspl ⇒ Object
Returns the value of attribute on_found_aspl.
Instance Method Summary collapse
- #attlist ⇒ Object
- #cdata ⇒ Object
- #comment(str) ⇒ Object
-
#initialize(&block) ⇒ IP360ASPLXMLStreamParser
constructor
A new instance of IP360ASPLXMLStreamParser.
- #instruction(name, instruction) ⇒ Object
- #reset_state ⇒ Object
- #tag_end(name) ⇒ Object
- #tag_start(name, attributes) ⇒ Object
- #text(str) ⇒ Object
-
#xmldecl(version, encoding, standalone) ⇒ Object
We don’t need these methods, but they’re necessary to keep REXML happy.
Constructor Details
#initialize(&block) ⇒ IP360ASPLXMLStreamParser
Returns a new instance of IP360ASPLXMLStreamParser.
16 17 18 19 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 16 def initialize(&block) reset_state on_found_aspl = block if block end |
Instance Attribute Details
#on_found_aspl ⇒ Object
Returns the value of attribute on_found_aspl.
14 15 16 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 14 def on_found_aspl @on_found_aspl end |
Instance Method Details
#attlist ⇒ Object
98 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 98 def attlist; end |
#cdata ⇒ Object
95 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 95 def cdata; end |
#comment(str) ⇒ Object
96 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 96 def comment(str); end |
#instruction(name, instruction) ⇒ Object
97 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 97 def instruction(name, instruction); end |
#reset_state ⇒ Object
21 22 23 24 25 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 21 def reset_state @aspl = {'vulns' => {'name' => { }, 'cve' => { }, 'bid' => { } }, 'oses' => {'name' => { } } } @state = :generic_state end |
#tag_end(name) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 64 def tag_end(name) case name when "ontology" on_found_aspl.call(@aspl) if on_found_aspl reset_state when "advisory" if (@x['pub'] =~ /CVE/) if (@cfirst == 0) @c += "," end @c += @x['refid'] @cfirst = 0 elsif (@x['pub'] =~ /BugTraq/) if (@bfirst == 0) @b += "," end @b += @x['refid'] @bfirst = 0 end when "advisories" @aspl['vulns']['cve'][@vulnid] = @c @aspl['vulns']['bid'][@vulnid] = @b @c = "" @b = "" end @state = :generic_state end |
#tag_start(name, attributes) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 27 def tag_start(name, attributes) case name when "vulns" @location = "vulns" when "vuln" @vulnid = attributes['id'].strip when "name" @state = :is_name when "advisories" @c = "" @cfirst = 1 @b = "" @bfirst = 1 @x = Hash.new when "publisher" @state = :is_pub when "id" @state = :is_refid when "operatingSystems" @location = "os" when "operatingSystem" @osid = attributes['id'].strip end end |
#text(str) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 52 def text(str) case @state when :is_name @aspl['vulns']['name'][@vulnid] = str if @location == "vulns" @aspl['oses'][@osid] = str if @location == "os" when :is_pub @x['pub'] = str when :is_refid @x['refid'] = str end end |
#xmldecl(version, encoding, standalone) ⇒ Object
We don’t need these methods, but they’re necessary to keep REXML happy
94 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 94 def xmldecl(version, encoding, standalone); end |