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

@@ -8,21 +8,15 @@ class WpItem
# Filters out already fixed vulnerabilities
#
# @return [ Vulnerabilities ]
def vulnerabilities
def vulnerabilities
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|
vulnerability = Vulnerability.load_from_json_item(vulnerability)
vulnerabilities << vulnerability if vulnerable_to?(vulnerability)
end
break # No need to iterate any further
json[identifier]['vulnerabilities'].each do |vulnerability|
vulnerability = Vulnerability.load_from_json_item(vulnerability)
vulnerabilities << vulnerability if vulnerable_to?(vulnerability)
end
vulnerabilities

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,25 +35,24 @@
}
]
},
{
"name": "white-rabbit",
"vulnerabilities": [
{
"id":2993,
"title":"Follow me!",
"references": {
"url": ["Ref 1", "Ref 2"],
"osvdb": ["osvdb"],
"cve": ["2011-001"],
"secunia": ["secunia"],
"metasploit": ["exploit/ex1"],
"exploitdb": ["exploitdb"]
},
"type":"REDIRECT",
"fixed_in":"",
"created_at":"2014-07-28T12:10:07.000Z",
"updated_at":"2014-07-28T12:10:07.000Z"
}
]
}
]
"white-rabbit": {
"vulnerabilities": [
{
"id":2993,
"title":"Follow me!",
"references": {
"url": ["Ref 1", "Ref 2"],
"osvdb": ["osvdb"],
"cve": ["2011-001"],
"secunia": ["secunia"],
"metasploit": ["exploit/ex1"],
"exploitdb": ["exploitdb"]
},
"type":"REDIRECT",
"fixed_in":"",
"created_at":"2014-07-28T12:10:07.000Z",
"updated_at":"2014-07-28T12:10:07.000Z"
}
]
}
}

View File

@@ -1,6 +1,5 @@
[
{
"name": "mr-smith",
{
"mr-smith": {
"vulnerabilities":[
{
"id":2989,
@@ -36,25 +35,25 @@
}
]
},
{
"name": "the-oracle",
"vulnerabilities":[
{
"id":2993,
"title":"I see you",
"references": {
"url": ["Ref 1", "Ref 2"],
"osvdb": ["osvdb"],
"cve": ["2011-001"],
"secunia": ["secunia"],
"metasploit": ["exploit/ex1"],
"exploitdb": ["exploitdb"]
},
"type":"FPD",
"fixed_in":"",
"created_at":"2014-07-28T12:10:07.000Z",
"updated_at":"2014-07-28T12:10:07.000Z"
}
]
"the-oracle": {
"vulnerabilities":[
{
"id":2993,
"title":"I see you",
"references": {
"url": ["Ref 1", "Ref 2"],
"osvdb": ["osvdb"],
"cve": ["2011-001"],
"secunia": ["secunia"],
"metasploit": ["exploit/ex1"],
"exploitdb": ["exploitdb"]
},
"type":"FPD",
"fixed_in":"",
"created_at":"2014-07-28T12:10:07.000Z",
"updated_at":"2014-07-28T12:10:07.000Z"
}
]
}
]
}

View File

@@ -1,6 +1,5 @@
[
{
"version": "3.5",
{
"3.5": {
"vulnerabilities":[
{
"id":2989,
@@ -19,9 +18,8 @@
"updated_at":"2014-07-28T12:10:07.000Z"
}
]
},
{
"version": "3.2",
},
"3.2": {
"vulnerabilities":[
{
"id":2993,
@@ -41,4 +39,4 @@
}
]
}
]
}