Fix for #694
This commit is contained in:
@@ -43,9 +43,11 @@ class Vulnerability
|
|||||||
def self.load_from_json_item(json_item)
|
def self.load_from_json_item(json_item)
|
||||||
references = {}
|
references = {}
|
||||||
|
|
||||||
[:url, :cve, :secunia, :osvdb, :metasploit, :exploitdb].each do |key|
|
%w(url cve secunia osvdb metasploit exploitdb).each do |key|
|
||||||
#json_item['id'] = json_item['id'].to_s.split(',')
|
if json_item[key]
|
||||||
references[key] = json_item[key.to_s].to_s.split(',') if json_item[key.to_s]
|
json_item[key] = [json_item[key]] if json_item[key].class != Array
|
||||||
|
references[key] = json_item[key]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
new(
|
new(
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ describe Vulnerability do
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected_refs = {
|
expected_refs = {
|
||||||
: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' }
|
||||||
@@ -51,4 +51,4 @@ describe Vulnerability do
|
|||||||
its(:fixed_in) { should == '1.0'}
|
its(:fixed_in) { should == '1.0'}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -14,12 +14,12 @@ 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) { {
|
||||||
: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
|
||||||
@@ -167,4 +167,4 @@ describe WpItem do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -8,12 +8,12 @@ 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) { {
|
||||||
: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
|
||||||
@@ -26,4 +26,4 @@ describe WpPlugin do
|
|||||||
its('uri.to_s') { is_expected.to eq 'http://example.com/wp-content/plugins/plugin-name/' }
|
its('uri.to_s') { is_expected.to eq 'http://example.com/wp-content/plugins/plugin-name/' }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -9,12 +9,12 @@ 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) { {
|
||||||
: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
|
||||||
@@ -32,4 +32,4 @@ describe WpTheme do
|
|||||||
its(:uri) { is_expected.to eq uri.merge(theme_path) }
|
its(:uri) { is_expected.to eq uri.merge(theme_path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -8,12 +8,12 @@ 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) { {
|
||||||
: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
|
||||||
@@ -28,4 +28,4 @@ describe WpVersion do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user