Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/parser/ip360_aspl_xml.rb
Views: 11779
# -*- coding: binary -*-1require 'rexml/document'23module Rex4module Parser567class IP360ASPLXMLStreamParser89@vulnid = nil10@appid = nil11@location = nil1213attr_accessor :on_found_aspl1415def initialize(&block)16reset_state17on_found_aspl = block if block18end1920def reset_state21@aspl = {'vulns' => {'name' => { }, 'cve' => { }, 'bid' => { } },22'oses' => {'name' => { } } }23@state = :generic_state24end2526def tag_start(name, attributes)27case name28when "vulns"29@location = "vulns"30when "vuln"31@vulnid = attributes['id'].strip32when "name"33@state = :is_name34when "advisories"35@c = ""36@cfirst = 137@b = ""38@bfirst = 139@x = Hash.new40when "publisher"41@state = :is_pub42when "id"43@state = :is_refid44when "operatingSystems"45@location = "os"46when "operatingSystem"47@osid = attributes['id'].strip48end49end5051def text(str)52case @state53when :is_name54@aspl['vulns']['name'][@vulnid] = str if @location == "vulns"55@aspl['oses'][@osid] = str if @location == "os"56when :is_pub57@x['pub'] = str58when :is_refid59@x['refid'] = str60end61end6263def tag_end(name)64case name65when "ontology"66on_found_aspl.call(@aspl) if on_found_aspl67reset_state68when "advisory"69if (@x['pub'] =~ /CVE/)70if (@cfirst == 0)71@c += ","72end73@c += @x['refid']74@cfirst = 075elsif (@x['pub'] =~ /BugTraq/)76if (@bfirst == 0)77@b += ","78end79@b += @x['refid']80@bfirst = 081end82when "advisories"83@aspl['vulns']['cve'][@vulnid] = @c84@aspl['vulns']['bid'][@vulnid] = @b85@c = ""86@b = ""87end88@state = :generic_state89end9091# We don't need these methods, but they're necessary to keep REXML happy92#93def xmldecl(version, encoding, standalone); end94def cdata; end95def comment(str); end96def instruction(name, instruction); end97def attlist; end98end99100end101end102103104