New json structure implemented #853

This commit is contained in:
ethicalhack3r
2015-09-03 22:04:44 +02:00
parent 57f6206aee
commit e6d29f6f18
9 changed files with 78 additions and 96 deletions

View File

@@ -172,19 +172,19 @@ class WpItems < Array
case type
when :vulnerable
item_names = json.select { |item| !item['vulnerabilities'].empty? }.map {|item| item['name'] }
items = json.select { |item| !json[item]['vulnerabilities'].empty? }
when :popular
item_names = json.select { |item| item['popular'] == true }.map {|item| item['name'] }
items = json.select { |item| json[item]['popular'] == true }
when :all
item_names = [*json].map { |item| item['name'] }
items = [*json]
else
raise "Unknown type #{type}"
end
item_names.each do |item_name|
items.each do |item|
targets << create_item(
item_class,
item_name,
item[0],
wp_target,
vulns_file
)

View File

@@ -12,19 +12,13 @@ class WpItem
json = json(vulns_file)
vulnerabilities = Vulnerabilities.new
json.each do |item|
asset = item['version'] || item['name']
return vulnerabilities if json.empty?
next unless asset == identifier
item['vulnerabilities'].each do |vulnerability|
json[identifier]['vulnerabilities'].each do |vulnerability|
vulnerability = Vulnerability.load_from_json_item(vulnerability)
vulnerabilities << vulnerability if vulnerable_to?(vulnerability)
end
break # No need to iterate any further
end
vulnerabilities
end

View File

@@ -1,6 +1,5 @@
[
{
"name": "mr-smith",
"mr-smith": {
"vulnerabilities":[
{
"id":2989,
@@ -48,8 +47,7 @@
}
]
},
{
"name": "neo",
"neo": {
"vulnerabilities":[
{
"id":2993,
@@ -63,4 +61,4 @@
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"name": "mr-smith",
"mr-smith": {
"vulnerabilities":[
{
"id":2989,
@@ -48,8 +47,7 @@
}
]
},
{
"name":"neo",
"neo": {
"vulnerabilities":[
{
"id":2993,
@@ -63,4 +61,4 @@
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"name": "shopperpress",
"shopperpress": {
"vulnerabilities":[
{
"id":2989,
@@ -48,8 +47,7 @@
}
]
},
{
"name": "webfolio",
"webfolio": {
"vulnerabilities":[
{
"id":2993,
@@ -63,4 +61,5 @@
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"name": "not-this-one",
"not-this-one": {
"vulnerabilities":[
{
"id":2989,
@@ -13,8 +12,7 @@
}
]
},
{
"name": "neo",
"neo": {
"vulnerabilities":[
{
"id":2993,
@@ -34,4 +32,4 @@
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"name": "mr-smith",
"mr-smith": {
"vulnerabilities":[
{
"id":2993,
@@ -36,8 +35,7 @@
}
]
},
{
"name": "white-rabbit",
"white-rabbit": {
"vulnerabilities": [
{
"id":2993,
@@ -57,4 +55,4 @@
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"name": "mr-smith",
"mr-smith": {
"vulnerabilities":[
{
"id":2989,
@@ -36,8 +35,7 @@
}
]
},
{
"name": "the-oracle",
"the-oracle": {
"vulnerabilities":[
{
"id":2993,
@@ -57,4 +55,5 @@
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"version": "3.5",
"3.5": {
"vulnerabilities":[
{
"id":2989,
@@ -20,8 +19,7 @@
}
]
},
{
"version": "3.2",
"3.2": {
"vulnerabilities":[
{
"id":2993,
@@ -41,4 +39,4 @@
}
]
}
]
}