Creation of a function xml instead of a hack for Nokogiri::XML

This commit is contained in:
erwanlr
2013-03-11 17:59:26 +01:00
parent 64c3c29597
commit de3d62ba92
7 changed files with 15 additions and 22 deletions

View File

@@ -46,7 +46,7 @@ class CheckerPlugin < Plugin
puts '[+] Checking vulnerabilities reference urls'
vuln_ref_files.each do |vuln_ref_file|
xml = Nokogiri::XML(File.open(vuln_ref_file))
xml = xml(vuln_ref_file)
urls = []
xml.xpath('//reference').each { |node| urls << node.text }
@@ -111,7 +111,7 @@ class CheckerPlugin < Plugin
puts '[+] Checking for vulnerable files ...'
xml = Nokogiri::XML(File.open(xml_file))
xml = xml(xml_file)
xml.xpath('//hash').each do |node|
sha1sum = node.attribute('sha1').text

View File

@@ -44,24 +44,20 @@ class StatsPlugin < Plugin
end
end
def xml(file)
Nokogiri::XML(File.open(file))
end
def vuln_plugin_count(file=PLUGINS_VULNS_FILE)
self.xml(file).xpath("count(//plugin)").to_i
xml(file).xpath("count(//plugin)").to_i
end
def vuln_theme_count(file=THEMES_VULNS_FILE)
self.xml(file).xpath("count(//theme)").to_i
xml(file).xpath("count(//theme)").to_i
end
def plugin_vulns_count(file=PLUGINS_VULNS_FILE)
self.xml(file).xpath("count(//vulnerability)").to_i
xml(file).xpath("count(//vulnerability)").to_i
end
def theme_vulns_count(file=THEMES_VULNS_FILE)
self.xml(file).xpath("count(//vulnerability)").to_i
xml(file).xpath("count(//vulnerability)").to_i
end
def total_plugins(file=PLUGINS_FULL_FILE, xml=PLUGINS_VULNS_FILE)