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.
17 18 19 20 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 17 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.
15 16 17 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 15 def on_found_aspl @on_found_aspl end |
Instance Method Details
#attlist ⇒ Object
99 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 99 def attlist; end |
#cdata ⇒ Object
96 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 96 def cdata; end |
#comment(str) ⇒ Object
97 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 97 def comment(str); end |
#instruction(name, instruction) ⇒ Object
98 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 98 def instruction(name, instruction); end |
#reset_state ⇒ Object
22 23 24 25 26 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 22 def reset_state @aspl = {'vulns' => {'name' => { }, 'cve' => { }, 'bid' => { } }, 'oses' => {'name' => { } } } @state = :generic_state end |
#tag_end(name) ⇒ Object
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 91 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 65 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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 28 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
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 53 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
95 |
# File 'lib/rex/parser/ip360_aspl_xml.rb', line 95 def xmldecl(version, encoding, standalone); end |