Fix bug in output
This commit is contained in:
@@ -43,8 +43,11 @@ class Vulnerability
|
|||||||
def self.load_from_json_item(json_item)
|
def self.load_from_json_item(json_item)
|
||||||
references = {}
|
references = {}
|
||||||
|
|
||||||
[:id, :url, :cve, :secunia, :osvdb, :metasploit, :exploitdb].each do |key|
|
%w(id url cve secunia osvdb metasploit exploitdb).each do |key|
|
||||||
references[key] = json_item[key.to_s].to_s.split(',') if json_item[key.to_s]
|
if json_item[key]
|
||||||
|
json_item[key] = [json_item[key]] if json_item[key].class != Array
|
||||||
|
references[key] = json_item[key]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
new(
|
new(
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ describe Vulnerability do
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected_refs = {
|
expected_refs = {
|
||||||
:id => ['3911'],
|
'id' => ['3911'],
|
||||||
:url => ['Ref 1', 'Ref 2'],
|
'url' => ['Ref 1,Ref 2'],
|
||||||
:cve => ['2011-001'],
|
'cve' => ['2011-001'],
|
||||||
:secunia => ['secunia'],
|
'secunia' => ['secunia'],
|
||||||
:osvdb => ['osvdb'],
|
'osvdb' => ['osvdb'],
|
||||||
:metasploit => ['exploit/ex1'],
|
'metasploit' => ['exploit/ex1'],
|
||||||
:exploitdb => ['exploitdb']
|
'exploitdb' => ['exploitdb']
|
||||||
}
|
}
|
||||||
|
|
||||||
its(:title) { should == 'Vuln Title' }
|
its(:title) { should == 'Vuln Title' }
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ describe WpItem do
|
|||||||
let(:vulns_file) { MODELS_FIXTURES + '/wp_item/vulnerable/items_vulns.json' }
|
let(:vulns_file) { MODELS_FIXTURES + '/wp_item/vulnerable/items_vulns.json' }
|
||||||
let(:identifier) { 'neo' }
|
let(:identifier) { 'neo' }
|
||||||
let(:expected_refs) { {
|
let(:expected_refs) { {
|
||||||
:id => ['2993'],
|
'id' => [2993],
|
||||||
:url => ['Ref 1', 'Ref 2'],
|
'url' => ['Ref 1,Ref 2'],
|
||||||
:cve => ['2011-001'],
|
'cve' => ['2011-001'],
|
||||||
:secunia => ['secunia'],
|
'secunia' => ['secunia'],
|
||||||
:osvdb => ['osvdb'],
|
'osvdb' => ['osvdb'],
|
||||||
:metasploit => ['exploit/ex1'],
|
'metasploit' => ['exploit/ex1'],
|
||||||
:exploitdb => ['exploitdb']
|
'exploitdb' => ['exploitdb']
|
||||||
} }
|
} }
|
||||||
let(:expected_vulns) { Vulnerabilities.new(1, Vulnerability.new("I'm the one", 'XSS', expected_refs)) }
|
let(:expected_vulns) { Vulnerabilities.new(1, Vulnerability.new("I'm the one", 'XSS', expected_refs)) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ describe WpPlugin do
|
|||||||
let(:options) { { name: 'white-rabbit' } }
|
let(:options) { { name: 'white-rabbit' } }
|
||||||
let(:vulns_file) { MODELS_FIXTURES + '/wp_plugin/vulnerable/plugins_vulns.json' }
|
let(:vulns_file) { MODELS_FIXTURES + '/wp_plugin/vulnerable/plugins_vulns.json' }
|
||||||
let(:expected_refs) { {
|
let(:expected_refs) { {
|
||||||
:id => ['2993'],
|
'id' => [2993],
|
||||||
:url => ['Ref 1', 'Ref 2'],
|
'url' => ['Ref 1,Ref 2'],
|
||||||
:cve => ['2011-001'],
|
'cve' => ['2011-001'],
|
||||||
:secunia => ['secunia'],
|
'secunia' => ['secunia'],
|
||||||
:osvdb => ['osvdb'],
|
'osvdb' => ['osvdb'],
|
||||||
:metasploit => ['exploit/ex1'],
|
'metasploit' => ['exploit/ex1'],
|
||||||
:exploitdb => ['exploitdb']
|
'exploitdb' => ['exploitdb']
|
||||||
} }
|
} }
|
||||||
let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('Follow me!', 'REDIRECT', expected_refs) }
|
let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('Follow me!', 'REDIRECT', expected_refs) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ describe WpTheme do
|
|||||||
let(:options) { { name: 'the-oracle' } }
|
let(:options) { { name: 'the-oracle' } }
|
||||||
let(:vulns_file) { MODELS_FIXTURES + '/wp_theme/vulnerable/themes_vulns.json' }
|
let(:vulns_file) { MODELS_FIXTURES + '/wp_theme/vulnerable/themes_vulns.json' }
|
||||||
let(:expected_refs) { {
|
let(:expected_refs) { {
|
||||||
:id => ['2993'],
|
'id' => [2993],
|
||||||
:url => ['Ref 1', 'Ref 2'],
|
'url' => ['Ref 1,Ref 2'],
|
||||||
:cve => ['2011-001'],
|
'cve' => ['2011-001'],
|
||||||
:secunia => ['secunia'],
|
'secunia' => ['secunia'],
|
||||||
:osvdb => ['osvdb'],
|
'osvdb' => ['osvdb'],
|
||||||
:metasploit => ['exploit/ex1'],
|
'metasploit' => ['exploit/ex1'],
|
||||||
:exploitdb => ['exploitdb']
|
'exploitdb' => ['exploitdb']
|
||||||
} }
|
} }
|
||||||
let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('I see you', 'FPD', expected_refs) }
|
let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('I see you', 'FPD', expected_refs) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ describe WpVersion do
|
|||||||
let(:options) { { number: '3.2' } }
|
let(:options) { { number: '3.2' } }
|
||||||
let(:vulns_file) { MODELS_FIXTURES + '/wp_version/vulnerable/versions_vulns.json' }
|
let(:vulns_file) { MODELS_FIXTURES + '/wp_version/vulnerable/versions_vulns.json' }
|
||||||
let(:expected_refs) { {
|
let(:expected_refs) { {
|
||||||
:id => ['2993'],
|
'id' => [2993],
|
||||||
:url => ['Ref 1', 'Ref 2'],
|
'url' => ['Ref 1,Ref 2'],
|
||||||
:cve => ['2011-001'],
|
'cve' => ['2011-001'],
|
||||||
:secunia => ['secunia'],
|
'secunia' => ['secunia'],
|
||||||
:osvdb => ['osvdb'],
|
'osvdb' => ['osvdb'],
|
||||||
:metasploit => ['exploit/ex1'],
|
'metasploit' => ['exploit/ex1'],
|
||||||
:exploitdb => ['exploitdb']
|
'exploitdb' => ['exploitdb']
|
||||||
} }
|
} }
|
||||||
let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('Here I Am', 'SQLI', expected_refs) }
|
let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('Here I Am', 'SQLI', expected_refs) }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user