Fix rspecs for new json

This commit is contained in:
ethicalhack3r
2014-07-31 14:08:49 +02:00
parent 187e2f1330
commit 420ad6cd37
7 changed files with 30 additions and 22470 deletions

View File

@@ -60,26 +60,27 @@ class StatsPlugin < Plugin
end
def version_vulns_count(file=WP_VULNS_FILE)
xml(file).xpath('count(//vulnerability)').to_i
asset_vulns_count(json(file))
end
def fix_version_count(file=WP_VULNS_FILE)
xml(file).xpath('count(//fixed_in)').to_i
asset_fixed_in_count(json(file))
end
def plugin_vulns_count(file=PLUGINS_VULNS_FILE)
json(file).xpath('count(//vulnerability)').to_i
asset_vulns_count(json(file))
end
def fix_plugin_count(file=PLUGINS_VULNS_FILE)
xml(file).xpath('count(//fixed_in)').to_i
asset_fixed_in_count(json(file))
end
def theme_vulns_count(file=THEMES_VULNS_FILE)
xml(file).xpath('count(//vulnerability)').to_i
asset_vulns_count(json(file))
end
def fix_theme_count(file=THEMES_VULNS_FILE)
xml(file).xpath('count(//fixed_in)').to_i
asset_fixed_in_count(json(file))
end
def total_plugins(file=PLUGINS_FULL_FILE)
@@ -94,4 +95,12 @@ class StatsPlugin < Plugin
IO.readlines(file).size
end
def asset_vulns_count(json)
json.map { |asset| asset[asset.keys.inject]['vulnerabilities'].size }.inject(:+)
end
def asset_fixed_in_count(json)
json.map { |asset| asset[asset.keys.inject]['vulnerabilities'].map {|a| a['fixed_in'].nil? ? 0 : 1 }.inject(:+) }.inject(:+)
end
end