Implemented Erwan's feedback
This commit is contained in:
@@ -143,28 +143,16 @@ class WpItems < Array
|
|||||||
def vulnerable_targets_items(wp_target, item_class, vulns_file)
|
def vulnerable_targets_items(wp_target, item_class, vulns_file)
|
||||||
targets = []
|
targets = []
|
||||||
json = json(vulns_file)
|
json = json(vulns_file)
|
||||||
# xml = xml(vulns_file)
|
|
||||||
|
|
||||||
unless json.nil? || json == ''
|
[*json].each do |item|
|
||||||
json.each do |item|
|
targets << create_item(
|
||||||
targets << create_item(
|
item_class,
|
||||||
item_class,
|
item.keys.inject,
|
||||||
item.keys.inject,
|
wp_target,
|
||||||
wp_target,
|
vulns_file
|
||||||
vulns_file
|
)
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# xml.xpath(item_xpath).each do |node|
|
|
||||||
# targets << create_item(
|
|
||||||
# item_class,
|
|
||||||
# node.attribute('name').text,
|
|
||||||
# wp_target,
|
|
||||||
# vulns_file
|
|
||||||
# )
|
|
||||||
# end
|
|
||||||
|
|
||||||
targets
|
targets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -35,32 +35,6 @@ class Vulnerability
|
|||||||
end
|
end
|
||||||
# :nocov:
|
# :nocov:
|
||||||
|
|
||||||
# Create the Vulnerability from the xml_node
|
|
||||||
#
|
|
||||||
# @param [ Nokogiri::XML::Node ] xml_node
|
|
||||||
#
|
|
||||||
# @return [ Vulnerability ]
|
|
||||||
# def self.load_from_xml_node(xml_node)
|
|
||||||
# references = {}
|
|
||||||
# refs = xml_node.search('references')
|
|
||||||
|
|
||||||
# if refs
|
|
||||||
# references[:url] = refs.search('url').map(&:text)
|
|
||||||
# references[:cve] = refs.search('cve').map(&:text)
|
|
||||||
# references[:secunia] = refs.search('secunia').map(&:text)
|
|
||||||
# references[:osvdb] = refs.search('osvdb').map(&:text)
|
|
||||||
# references[:metasploit] = refs.search('metasploit').map(&:text)
|
|
||||||
# references[:exploitdb] = refs.search('exploitdb').map(&:text)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# new(
|
|
||||||
# xml_node.search('title').text,
|
|
||||||
# xml_node.search('type').text,
|
|
||||||
# references,
|
|
||||||
# xml_node.search('fixed_in').text,
|
|
||||||
# )
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Create the Vulnerability from the json_item
|
# Create the Vulnerability from the json_item
|
||||||
#
|
#
|
||||||
# @param [ Hash ] json_item
|
# @param [ Hash ] json_item
|
||||||
@@ -69,12 +43,9 @@ class Vulnerability
|
|||||||
def self.load_from_json_item(json_item)
|
def self.load_from_json_item(json_item)
|
||||||
references = {}
|
references = {}
|
||||||
|
|
||||||
references[:url] = json_item['references'].split(',') if json_item['references']
|
[:url, :cve, :secunia, :osvdb, :metasploit, :exploitdb].each do |key|
|
||||||
references[:cve] = json_item['cve'].split(',') if json_item['cve']
|
references[key] = json_item[key.to_s].split(',') if json_item[key.to_s]
|
||||||
references[:secunia] = json_item['secunia'].split(',') if json_item['secunia']
|
end
|
||||||
references[:osvdb] = json_item['osvdb'].split(',') if json_item['osvdb']
|
|
||||||
references[:metasploit] = json_item['metasploit'].split(',') if json_item['metasploit']
|
|
||||||
references[:exploitdb] = json_item['exploitdb'].split(',') if json_item['exploitdb']
|
|
||||||
|
|
||||||
new(
|
new(
|
||||||
json_item['title'],
|
json_item['title'],
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ class WpItem
|
|||||||
#
|
#
|
||||||
# @return [ Vulnerabilities ]
|
# @return [ Vulnerabilities ]
|
||||||
def vulnerabilities
|
def vulnerabilities
|
||||||
# xml = xml(vulns_file)
|
|
||||||
json = json(vulns_file)
|
json = json(vulns_file)
|
||||||
vulnerabilities = Vulnerabilities.new
|
vulnerabilities = Vulnerabilities.new
|
||||||
|
|
||||||
@@ -24,13 +23,6 @@ class WpItem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# xml.xpath(vulns_xpath).each do |node|
|
|
||||||
# vuln = Vulnerability.load_from_xml_node(node)
|
|
||||||
# if vulnerable_to?(vuln)
|
|
||||||
# vulnerabilities << vuln
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
vulnerabilities
|
vulnerabilities
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,4 +47,9 @@ class WpItem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [ String ]
|
||||||
|
def identifier
|
||||||
|
@name
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,15 +11,5 @@ class WpPlugin < WpItem
|
|||||||
@vulns_file
|
@vulns_file
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [ String ]
|
|
||||||
def identifier
|
|
||||||
@name
|
|
||||||
end
|
|
||||||
|
|
||||||
# # @return [ String ]
|
|
||||||
# def vulns_xpath
|
|
||||||
# "//plugin[@name='#{@name}']/vulnerability"
|
|
||||||
# end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,15 +11,5 @@ class WpTheme < WpItem
|
|||||||
@vulns_file
|
@vulns_file
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [ String ]
|
|
||||||
def identifier
|
|
||||||
@name
|
|
||||||
end
|
|
||||||
|
|
||||||
# @return [ String ]
|
|
||||||
# def vulns_xpath
|
|
||||||
# "//theme[@name='#{@name}']/vulnerability"
|
|
||||||
# end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user